g++ 2.95.2 fails to enforce access rules

Sun Dec 26 11:21:00 GMT 1999


the program below compiles with g++ 2.95.2 despite the fact that C<>::Private is inaccessible.


$ cat test.cpp

template <class T>
struct S
    typedef typename T::Private X;

template <class T>
class C {
    typedef T Private;

template class S<C<int> >;

$ g++ -v -c test.cpp
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/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__ /build/sebor/dev/stdlib2/tests/regress/src/test.cpp /tmp/ccr14Fve.ii
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cc1plus /tmp/ccr14Fve.ii -quiet -dumpbase test.cc -version -o /tmp/ccoQlvmk.s
GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled by GNU C version 2.95.2 19991024 (release).
 as -V -Qy -o test.o /tmp/ccoQlvmk.s
GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version

--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

More information about the Gcc-bugs mailing list