the following program with a basic template struct which inherit another basic
template struct does not compile:
g++ bug_template_template.cc 
bug_template_template.cc: In member function ‘void U<C>::f()’:
bug_template_template.cc:6: error: ‘i’ was not declared in this scope
the output of g++ -v -save-temps follows the source file
the preprocessed file .ii is at the end of this report

template <class C> struct T{
        int i;
        C c;
};
template <class C> struct U:T<C>{
        void f(){i=0;}
};


g++ -v -save-temps bug_template_template.cc 
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.4-3'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--with-arch-32=i486 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.4 (Debian 4.4.4-3) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
 /usr/lib/gcc/x86_64-linux-gnu/4.4.4/cc1plus -E -quiet -v -D_GNU_SOURCE
bug_template_template.cc -mtune=generic -fpch-preprocess -o
bug_template_template.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.4.4/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.4
 /usr/include/c++/4.4/x86_64-linux-gnu
 /usr/include/c++/4.4/backward
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include
 /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
 /usr/lib/gcc/x86_64-linux-gnu/4.4.4/cc1plus -fpreprocessed
bug_template_template.ii -quiet -dumpbase bug_template_template.cc
-mtune=generic -auxbase bug_template_template -version -o
bug_template_template.s
GNU C++ (Debian 4.4.4-3) version 4.4.4 (x86_64-linux-gnu)
        compiled by GNU C version 4.4.4, GMP version 4.3.2, MPFR version
2.4.2-p1.
GGC heuristics: --param ggc-min-expand=57 --param ggc-min-heapsize=51739
GNU C++ (Debian 4.4.4-3) version 4.4.4 (x86_64-linux-gnu)
        compiled by GNU C version 4.4.4, GMP version 4.3.2, MPFR version
2.4.2-p1.
GGC heuristics: --param ggc-min-expand=57 --param ggc-min-heapsize=51739
Compiler executable checksum: a92c574e76687c18572fdbea97434cec
bug_template_template.cc: In member function ‘void U<C>::f()’:
bug_template_template.cc:6: error: ‘i’ was not declared in this scope


 cat bug_template_template.ii 
# 1 "bug_template_template.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "bug_template_template.cc"
template <class C> struct T{
 int i;
 C c;
};
template <class C> struct U:T<C>{
 void f(){i=0;}
};


-- 
           Summary: basic template struct has no direct access to members of
                    a basic parent template struct
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at razorcam dot com


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

Reply via email to