------- Comment #3 from vz-gcc at zeitlins dot org 2006-02-18 22:47 ------- First, thanks a lot Andrew for your lightning fast reply, this is really amazing -- and incredibly helpful!
Second, really sorry, rereading the explicit specialization section once again I see that I was indeed wrong and that "template <>" is really needed. Third, unfortunately PR 11930 does not help with my test case: % cat -n stsp.cpp 1 enum V { V1, V2, V3 }; 2 3 template <V v> struct Data { static int Value; }; 4 5 template struct Data<V1>; 6 7 template <> int Data<V1>::Value; 8 9 int main() { return Data<V1>::Value; } % g++-4.0 -o stsp -Wall stsp.cpp /tmp/ccywXRfg.o: In function `main':stsp.cpp:(.text+0x1d): undefined reference to `Data<(V)0>::Value' collect2: ld returned 1 exit status It looks like the compiler interprets the line 7 as declaration and not definition? If I add an initializer (i.e. change the line to end with "Value = 17" or "Value(17)") then it works just fine. Unfortunately in the real code the static member is a class and, worse, a class with only default ctor so I can't use "Value()" (which would be parsed as a function declaration) to force recognizing it such. Sorry in advance if I'm missing something again but it doesn't seem normal that no definition is emitted for the example above, does it? Thanks again for your help! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26355