According to the C++ standard each member specialization has to be declared 
before use. G++ accepts usage without prior declaration, see the thread 
starting 
at http://gcc.gnu.org/ml/gcc-help/2005-07/msg00074.html for a discussion.

The code shown below is accepted by g++ 4.0 (and 3.3 and 3.4), however it 
should 
report an error as Comeau and icc does. It should require the declarations 
which 
are commented out.

struct A {
 const A* a;
};

template <const char* c> struct B {
 static const A b;
};

extern const char c[1]="";
extern const char d[1]="";

// Should be required, g++ does not need them
//template<> const A B<d>::b;
//template<> const A B<c>::b;

template<> const A B<c>::b ={&B<d>::b};
template<> const A B<d>::b ={&B<c>::b};

-- 
           Summary: g++ accepts specializiation without declaration
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tneumann at pi3 dot informatik dot uni-mannheim dot de
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to