Bug 3774 – should not be able to implicitly cast to private base class
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
All
Creation time
2010-02-05T18:05:00Z
Last change time
2014-02-15T13:13:32Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
bugzilla
Comments
Comment #0 by bugzilla — 2010-02-05T18:05:00Z
It seems I have been testing this with a buggy c++ compiler or
can't remember what was the problem previously. I now tried with gcc
4.4.3 and this is how D and C++ differ:
---
class Foo {
public:
void bar() {}
};
class Bar : private Foo {
};
int main() {
Foo *a = new Bar();
a->bar();
}
test.cpp: In function ‘int main()’:
test.cpp:10: error: ‘Foo’ is an inaccessible base of ‘Bar’
---
module m1;
class Foo {
public void bar() {}
}
class Bar : private foo {
}
module m2;
import m1;
void main() {
Foo a = new Bar();
a.bar();
}
// compiles and runs just fine
// Changing the 'Foo a = ...' into 'Bar a = ...' makes this an error
Comment #1 by smjg — 2010-03-17T13:19:28Z
*** This issue has been marked as a duplicate of issue 2563 ***