This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/68161] New: Inconsistent behaviour of unnamed field with inheritance.
- From: "gpderetta at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Oct 2015 15:19:02 +0000
- Subject: [Bug c++/68161] New: Inconsistent behaviour of unnamed field with inheritance.
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68161
Bug ID: 68161
Summary: Inconsistent behaviour of unnamed field with
inheritance.
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gpderetta at gmail dot com
Target Milestone: ---
As an extension to C++, g++ allows the following:
struct B {
struct { int bar; };
};
int main()
{
B foo;
(void)foo.bar; // ok
}
The following does not work though:
struct A {
int bar;
};
struct B {
struct : A {};
};
int main()
{
B foo;
(void)foo.bar; // error: 'struct B' has no member named 'bar'
}
As unnamed struct fields are an extension, this is not really a bug as g++ can
do whatever it wants, but it does seems inconsistent.
The expected behaviour is useful to inject arbitrary names as members.