This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13445] New: Template argument replacement "dereferences" a typedef


Every version of gcc 3.3.2 I've tested has the bug.  I built a copy by
downloading sources from ftp.gnu.org to be sure no distribution-specific patches
were to blame:

../gcc-3.3.2/configure \
  --prefix=/home/kingb/Temp/gcc-3.3.2-install \
  --enable-languages=c,c++
make bootstrap
make install

"g++ --version" reports "g++ (GCC) 3.3.2"

The following code reproduces the problem.  It is expected to compile without error:

template <class T> class NestedBase {};
template <class T> class Base { protected: typedef int Protected; };
template <class T> struct Derived: public Base<T>
{
  typedef typename Base<T>::Protected Public;
  class Nested: public NestedBase<Public> {};
};
template class Derived<int>::Nested;

Compiling the source with "./g++ -c bug.cxx" produces this error:

bug.cxx: In instantiation of `Derived<int>::Nested':
bug.cxx:8:   instantiated from here
bug.cxx:2: error: `typedef int Base<int>::Protected' is protected
bug.cxx:8: error: within this context

We see that the "Public" typedef is "dereferenced" while instantiating the
template member class "Nested", which produces the access violation.

Compiling the same source with g++ 3.2.3 or any earlier GCC version produces no
error.

-- 
           Summary: Template argument replacement "dereferences" a typedef
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brad dot king at kitware dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]