Dear all,

I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.

We use the compiler to generate code for a PowerPC processor.

Used invokation line for the GNU C++ compiler:

ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
      -fmerge-templates -mmultiple -mno-string -mstrict-align -O3
      -fno-exceptions -fno-rtti -fno-builtin-printf
      -I<different include paths>
      -D<differen #define's>
      X.CPP -oX.O


// file X.CPP

#define MODE 2                      // set MODE to 1 or 2

template <typename T_>
struct S
{
    int f (const T_&) const { return 0; }
    static int s;
};

#if (MODE == 1)

// template <>                      // declaration of S<char>::f
int S<char>::f (const char&) const;

// template <>                      // declaration of S<char>::s
int S<char>::s;

#elif (MODE == 2)

// template <>                      // definition of S<char>::f
int S<char>::f (const char&) const
{ return 1; }

// template <>                      // definition of S<char>::s
int S<char>::s = 2;

#endif


We have a template class S<> whose members should be explicitly specialized
for S<char>.
The program can be translated in two versions: if we set MODE to 1 we only
get a declaration of the specialized members, if we set MODE to 2 we get a
definition of these members.

Set mode to 1: The compiler accepts the declarations without the preceeding
"template<>" phrase. This is not standard compliant (see 14.7.3/1 and
14.7.3/15).

Set mode to 2: The compiler accepts the definitions without the preceeding
"template<>" phrase. This is also not standard compliant (see 14.7.3/16).

Kind regards
W. Roehrl

-- 
           Summary: explicit specialization of template class members
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wolfgang dot roehrl at de dot gi-de dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.5.1
  GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks


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

Reply via email to