[LC++]template code not accepted by GCC 3.0.4

Shaul Karl shaulka at bezeqint.net
Wed May 15 05:45:07 UTC 2002

> Hi,
> My girlfriend has some code that used to compile with GCC 2.95, but
> received a report from a GCC 3.0.4 user that some code does not
> compile. This is a typedef of a specialization of std::set.
> Since we can't upgrade to GCC 3.0.4 at home (I don't want to mess
> my Linux box, and have not enough disk space atm, and last time I
> tried to upgrade to 2.95.3, nasty things happened (though I managed
> to recover the trouble)), and that the latest cygwin version still
> sports 2.95.3 for win2k box at work, we can't test anything.
> This is some code that feature the faulty lines, in hope that it
> actually fails to compile with 3.0.4. It does compile with 2.95.
> I'd appreciate if someone could point out what actually is wrong.
> Before you say that, yes, I do know that it misses a using namespace
> STL declaration (we found that GCC oddly doesn't honor the std
> namespace by default, probably for backward compatibility reasons),
> but fully qualifying std::set does not help.
> The error messages reported by the GCC 3.0.4 user were, depending
> on some variations my girlfriend asked him to make:
> (non verbatim):
> ISO standard forbids to declare 'set' without type
> template-id 'set<Place>' can't be used as a declarator
> and (verbatim):
> src/selected.h:31: `set' is not a template
> src/selected.h:31: ISO C++ forbids declaration of `set2d' with no type
> This is the actual snippet. The original code can be found in the
> eme package at http://annie.kezako.net/eme/
> #include <set>
> class C {
> };
> class A {
>   typedef set<C> my_set;
> };
> int main()
> {
>   return 0;
> }
> Thanks,
> -- 
> Vincent Penquerc'h 

I have managed to compile the snippet you gave. The only change is to replace set with std::set in the typedef line. I didn't follow the link you gave to the original code.

$ cat main.cc 
#include <set>

class C {

class A {
    typedef std::set<C> my_set;

int main()
    return 0;

$ g++-3.0 -Wall main.cc 

$ g++-3.0 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.4/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.0.4

Or did I missed something?

    Shaul Karl, shaulka at bezeqint.n e t

More information about the tuxCPProgramming mailing list