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++/58661] New: Definition of inherited nested class should be invalid


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

            Bug ID: 58661
           Summary: Definition of inherited nested class should be invalid
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeratul976 at hotmail dot com

GCC accepts the following code without any errors:


struct A 
{
    struct nested;
};

struct B : public A {};

struct B::nested {};


I believe that this code is invalid according to [class] p11:

"If a class-head-name contains a nested-name-specifier, the class-specifier
shall refer to a class that was previously declared directly in the class or
namespace to which the nested-name-specifier refers, or in an element of the
inline namespace set (7.3.1) of that namespace (i.e., not merely inherited or
introduced by a using-declaration)"

Note that clang rejects the above code, with the error:

test.cpp:8:11: error: no struct named 'nested' in 'B'
struct B::nested {};
       ~~~^


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