[Bug c++/62064] New: Private inheritance and conversion function id in class member access
roger.ferrer at bsc dot es
gcc-bugzilla@gcc.gnu.org
Fri Aug 8 15:37:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62064
Bug ID: 62064
Summary: Private inheritance and conversion function id in
class member access
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: roger.ferrer at bsc dot es
Hi,
the snippet below causes an access error in g++ 4.9.1 if the
conversion-function-id is referenced in a class-member access.
Intel C++ 14.0.2 and clang 3.3 accept it.
This problem can be worked around with -fno-access-control
(There is also some weirdness like 'struct A A::A' in the diagnostic messages
themselves, but I guess this would belong to another bug)
Should the code be ill-formed, then the "OK" case should be rejected as well.
// -- test.cc
struct A
{
typedef int some_type;
operator some_type();
};
struct B : private A
{
typedef bool some_type;
void foo(B &r)
{
B *p;
B o;
A::operator A::some_type(); // OK
o.A::operator A::some_type(); // ERR
r.A::operator A::some_type(); // ERR
p->A::operator A::some_type(); // ERR
(*this).A::operator A::some_type(); // ERR
}
};
// -- end of test.cc
$ g++ --version
g++ (Debian 4.9.1-1) 4.9.1
$ g++ -c test.cc
test.cc: In member function ‘void B::foo(B&)’:
test.cc:3:1: error: ‘struct A A::A’ is inaccessible
{
^
test.cc:18:23: error: within this context
o.A::operator A::some_type(); // ERR
^
test.cc:4:17: error: ‘typedef int A::some_type’ is inaccessible
typedef int some_type;
^
test.cc:18:26: error: within this context
o.A::operator A::some_type(); // ERR
^
test.cc:3:1: error: ‘struct A A::A’ is inaccessible
{
^
test.cc:19:23: error: within this context
r.A::operator A::some_type(); // ERR
^
test.cc:4:17: error: ‘typedef int A::some_type’ is inaccessible
typedef int some_type;
^
test.cc:19:26: error: within this context
r.A::operator A::some_type(); // ERR
^
test.cc:3:1: error: ‘struct A A::A’ is inaccessible
{
^
test.cc:20:24: error: within this context
p->A::operator A::some_type(); // ERR
^
test.cc:4:17: error: ‘typedef int A::some_type’ is inaccessible
typedef int some_type;
^
test.cc:20:27: error: within this context
p->A::operator A::some_type(); // ERR
^
test.cc:3:1: error: ‘struct A A::A’ is inaccessible
{
^
test.cc:21:29: error: within this context
(*this).A::operator A::some_type(); // ERR
^
test.cc:4:17: error: ‘typedef int A::some_type’ is inaccessible
typedef int some_type;
^
test.cc:21:32: error: within this context
(*this).A::operator A::some_type(); // ERR
^
Kind regards,
More information about the Gcc-bugs
mailing list