Apparently g++ isn't recognizing protected members in inheritance before the 
class declaration.  Furthermore, G++ segfaults when adding the first line, and 
the friend class.

----------------------

[EMAIL PROTECTED]:~ $ cat a.cc
class Foo;

template <class T> class A
{ friend class Foo; protected: typedef T someType; };

template <class T> class B
{ protected: typedef T anotherType; };

template <typename T, template <class> class X, template <class> class Y>
class Foo : public X <T>, public Y <typename X<T>::someType>
{ typedef Y<typename X<T>::someType> yetAnotherType; };

int main ()
{ Foo<int, A, B> x; return 0; }

-------------

[EMAIL PROTECTED]:~ $ g++40 -v -save-temps -o a a.cc
Using built-in specs.
Configured with: ./..//gcc-4.0-20050130/configure --disable-nls --with-system-
zlib --with-libiconv-prefix=/usr/local --program-suffix=40 --with-gxx-include-
dir=/usr/local/lib/gcc/i386-portbld-freebsd5.3/4.0.0/include/c++/ --disable-
shared --disable-libgcj --prefix=/usr/local i386-portbld-freebsd5.3
Thread model: posix
gcc version 4.0.0 20050130 (experimental) [FreeBSD]
 /usr/local/libexec/gcc/i386-portbld-freebsd5.3/4.0.0/cc1plus -E -quiet -v 
a.cc -fpch-preprocess -o a.ii
ignoring nonexistent directory "/usr/local/lib/gcc/i386-portbld-
freebsd5.3/4.0.0/../../../../i386-portbld-freebsd5.3/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/i386-portbld-freebsd5.3/4.0.0/include/c++/
 /usr/local/lib/gcc/i386-portbld-freebsd5.3/4.0.0/include/c++//i386-portbld-
freebsd5.3
 /usr/local/lib/gcc/i386-portbld-freebsd5.3/4.0.0/include/c++//backward
 /usr/local/include
 /usr/local/lib/gcc/i386-portbld-freebsd5.3/4.0.0/include
 /usr/include
End of search list.
 /usr/local/libexec/gcc/i386-portbld-freebsd5.3/4.0.0/cc1plus -fpreprocessed 
a.ii -quiet -dumpbase a.cc -auxbase a -version -o a.s
GNU C++ version 4.0.0 20050130 (experimental) [FreeBSD] (i386-portbld-
freebsd5.3)
        compiled by GNU C version 4.0.0 20050130 (experimental) [FreeBSD].
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
a.cc:10: error: 'Foo' is not a template type
a.cc: In function 'int main()':
a.cc:14: error: 'Foo' is not a template
a.cc:13: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

----------------------

[EMAIL PROTECTED]:~ $ cat a.ii
# 1 "a.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.cc"
class Foo;

template <class T> class A
{ friend class Foo; protected: typedef T someType; };

template <class T> class B
{ protected: typedef T anotherType; };

template <typename T, template <class> class X, template <class> class Y>
class Foo : public X <T>, public Y <typename X<T>::someType>
{ typedef Y<typename X<T>::someType> yetAnotherType; };

int main ()
{ Foo<int, A, B> x; return 0; }

-- 
           Summary: problem with protected members in template inheritance
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jcobyrne at cox dot net
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to