c++/8389: [mainline regression] Access to members of base class & templates

bangerth@dealii.org bangerth@dealii.org
Tue Oct 29 08:48:00 GMT 2002


Old Synopsis: Cannot access protected member in base class
New Synopsis: [mainline regression] Access to members of base class & templates

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Tue Oct 29 07:39:14 2002
State-Changed-Why:
    Confirmed. It works in 3.2.1pre, though. The shortest example
    I can come up with is this:
    ----------------------------------
    template <class>
    class Base {
      protected:
        typedef int Type;
    };
    
    template <class T>
    struct Derived : public Base<T> {
        typedef typename Base<T>::Type Type;
    
        template <class Arg>
        void f(Type = Type()) {};
    };
    
    template void Derived<char>::f<int> (Type);
    -----------------------------------
    Making one of the templates a non-template makes the bug
    go away. What is also surprising is the three-fold output
    gcc gives:
    --------------------------------------
    tmp/g> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -ansi -pedantic -W -Wall -c x.cc
    x.cc:4: error: `typedef int Base<char>::Type' is protected
    x.cc:12: error: within this context
    x.cc:4: error: `typedef int Base<char>::Type' is protected
    x.cc:12: error: within this context
    x.cc:4: error: `typedef int Base<char>::Type' is protected
    x.cc:15: error: within this context
    --------------------------------------

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8389



More information about the Gcc-bugs mailing list