[Bug c++/55436] g++ compiles invalid code with child class of nested class in template class

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 22 12:58:00 GMT 2012


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid, wrong-code

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-11-22 12:58:19 UTC ---
This is also a wrong-code and rejects-valid bug.

This correct program shows the wrong m() being called (and so results in a
linker error)


template<typename T>
struct A
{
  static void m() { }

  struct B
  {
    void m();
  };

  struct C : B
  {
    void x() { m(); }
  };
};

int main()
{
  A<double>::C c;
  c.x();
}

and if we make B::m private we get rejects-valid

.cc: In member function ‘void A<T>::C::x() [with T = double]’:
x.cc:21:7:   instantiated from here
x.cc:9:10: error: ‘void A<T>::B::m() [with T = double]’ is private
x.cc:14:16: error: within this context



More information about the Gcc-bugs mailing list