Inner template classes confuse gcc-2.95 and gcc-2.95.1 compiler

Michael Vance briareos@lokigames.com
Fri Aug 27 11:36:00 GMT 1999


The following code causes incorrect compiler errors on gcc-2.95 with
Mumit Khan's patches, and straight gcc-2.95.1 built on a SuSE 6.2
machine. The info dump is obviously from the gcc-2.95 version. This
code compiles correctly on egcs-1.1.2 release. Mumit said that this
also compiles fine on his copy of gcc.

#include <list>

class NF {

    class K {
    public:
    K( void ) { };
    virtual ~K( ) { };
    virtual void foo( void ) { };
    };

    template<class T>
    class L : public std::list<T*>
    {
    public:
    L( void ) { };
    void find( void ) { };
    };

    class M {
    public:
    M( void ) { };
    virtual ~M( void ) { };
    virtual void bar( void ) { };
    };

    template<class T>
    class LH : public M, public L<T>, public K {
    public:
    LH( void ) { };
    virtual ~LH( void ) { };
    };

    class S : public K
    {
    friend LH<char>;
    friend LH<int>;
    friend LH<float>;

    char a;
    int b;
    float c;
    public:
    S( void ) { };
    };

};

int main( int argc, char* argv[] )
{
    return 0;
}

[michael@namaste HG2]$ gcc -v --save-temps -o dummy dummy.cpp
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/specs
gcc version 2.95 19990728 (release)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/cpp -lang-c++ -v
-D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__
-Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__
-D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386)
-Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro
-D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ dummy.cpp dummy.ii
GNU CPP version 2.95 19990728 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/../../../../include/g++-3
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/../../../../include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/include
 /usr/include
End of search list.
The following default directories have been omitted from the search
path:
End of omitted list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/cc1plus dummy.ii -quiet 
-dumpbase dummy.cc -version -o dummy.s
GNU C++ version 2.95 19990728 (release) (i686-pc-linux-gnu) compiled
by GNU C version 2.95 19990728 (release).
dummy.cpp:36: `LH' is not a template
dummy.cpp:36: ANSI C++ forbids declaration `' with no type
dummy.cpp:37: `LH' is not a template
dummy.cpp:37: ANSI C++ forbids declaration `' with no type
dummy.cpp:38: `LH' is not a template
dummy.cpp:38: ANSI C++ forbids declaration `' with no type
dummy.cpp:16: confused by earlier errors, bailing out

Regards,

m.

-- 
"How wonderful! How mysterious                                   Programmer
 I carry wood! I draw water!"                   Loki Entertainment Software
 - Anonymous Tao poet


More information about the Gcc-bugs mailing list