c++/9991: locale_facets.h contains invalid typedef

nasgaard@ca.ibm.com nasgaard@ca.ibm.com
Fri Mar 7 17:26:00 GMT 2003


>Number:         9991
>Category:       c++
>Synopsis:       locale_facets.h contains invalid typedef
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 07 17:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Howard Nasgaard
>Release:        unknown-1.0
>Organization:
>Environment:
This problem has been observed on both Mac OSX and Linux PPC systems.
>Description:
The problem here is on or about line 178 in locale_facets.h.

typedef typename ctype::mask      mask;

This typedef is illegal based on the latest C++ standard and, while g++ compiles with no problem, the IBM C++ compiler flags this as an error. The following is a reduced version of the same construct.

class ctype_base
{
public:

    typedef unsigned short mask;
};

template <class _CharT>
class __ctype_abstract_base : public ctype_base
{
public:
};

template <class _CharT>
class ctype : public __ctype_abstract_base<_CharT>
{
public:
   typedef typename ctype::mask      mask;
};

int main()
{
   ctype<char> cc;
   return 0;
}

This should be flagged as an error but it's not.  I expect the correct line should be:
typedef typename __ctype_abstract_base<_CharT>::mask mask;

The applicable part of the standard is:
"In the definition of a class template or a member of a class template, if a base class of the class template depends on a template-parameter, the base class scope is not examined during unqualified name lookup either at the point of definition of the class template or member or during an instantiation of the class template or member."
>How-To-Repeat:
gcc a.C
And it SHOULD fail, but doesn't.

Here's the output from a compile:
Reading specs from /usr/lib/gcc-lib/powerpc-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit powerpc-suse-linux
Thread model: posix
gcc version 3.2
 /usr/lib/gcc-lib/powerpc-suse-linux/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -DPPC -D__ELF__ -Dpowerpc -D__PPC__ -D__ELF__ -D__powerpc__ -D__PPC -D__powerpc -Acpu=powerpc -Amachine=powerpc -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -D_CALL_SYSV -D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine=bigendian -D_ARCH_PPC -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=unix -Asystem=posix a.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase a.C -version -o /home/nasgaard/tmp/cccA3faS.s
GNU CPP version 3.2 (cpplib) (PowerPC GNU/Linux)
GNU C++ version 3.2 (powerpc-suse-linux)
        compiled by GNU C version 3.2.
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/include/g++/powerpc-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/powerpc-suse-linux/3.2/include
 /usr/powerpc-suse-linux/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/powerpc-suse-linux/3.2/../../../../powerpc-suse-linux/bin/as -mppc -V -Qy -o a.o /home/nasgaard/tmp/cccA3faS.s
GNU assembler version 2.12.90.0.15 (powerpc-suse-linux) using BFD version 2.12.90.0.15 20020717 (SuSE)
>Fix:
I believe the fix should be:
typedef typename __ctype_abstract_base<_CharT>::mask mask;
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list