This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug regression/26355] New: defining static members of specialized template classes doesn't work


I'm not 100% sure if this is a compiler bug or a bug in my code but I think
that what I'm trying to do should be valid according to 14.7.5/4 of the C++
Standard. Please consider the following example:

% cat stsp.cpp
enum V { V1, V2, V3 };

template <V v> struct Data { static int Value; };

int Data<V1>::Value;

extern int GetIt() { return Data<V1>::Value; }


Compiling this with g++ 4.0 or 4.1 doesn't work:

% g++-4.0 -c -Wall stsp.cpp
stsp.cpp:5: error: too few template-parameter-lists
% g++-4.1 -c -Wall stsp.cpp
stsp.cpp:5: error: too few template-parameter-lists

While it works with all the previous versions (down to 2.95!).

g++4 does accept the explicit specialization of the static member if you
prepend "template <>" to "Data<V1>::Value" line which, IMHO, wrong too. But it
doesn't define the symbol in the object file in this case.

If this is really not allowed then it would be nice to make the error message
more clear.


-- 
           Summary: defining static members of specialized template classes
                    doesn't work
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vz-gcc at zeitlins dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26355


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]