Dear Richard, On 2/8/21 3:20 PM, Richard B. Kreckel wrote:
On 08.02.21 12:04, Alexey Sheplyakov wrote:
On 2/3/21 6:50 PM, Richard B. Kreckel via GiNaC-devel wrote:
commit f271f67d2fc798079326e450bc0e53eb80fb2e96 Author: Richard Kreckel <kreckel@ginac.de> Date: Wed Feb 3 14:40:49 2021 +0100
Avoid "instantiation of variable 'reg_info' required..." warning. With -Wundefined-var-template (on by default), CLang++ warns that no definition for the static 'reg_info' member variable is available.
The patch confuses me a bit.
Firstly, the compiler has complained about missing instantiation, and you've provided (an explicit) specialization instead. Yet the compiler seems to be happy.
Secondly this
/** Definition of container::reg_info for exprseq. */ template<> registered_class_info exprseq::reg_info;
is a declaration, not definition. According to 14.7.3.13 "An explicit specialization of a static data member of a template is a definition if the declaration includes an initializer; otherwise, it's a declaration."
I was following this advice here <https://stackoverflow.com/questions/56463004/fixing-warning-wundefined-var-template>.
That program is ill formed, since there's the explicit specialization of A<double>::name in the a.cpp translation unit, but not in others. The error message is not very clear, however according to the standard no diagnostics is required in this case. And in lst.cpp we've got an explicit specialization of lst::reg_info. So the declaration you've added is correct and required. However both the commit message and the comments in {lst,exprseq}.h are misleading. Best regards, Alexey