D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5299 - Protected inheritance is semantically undefined.
Summary: Protected inheritance is semantically undefined.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: spec
: 177 (view as issue list)
Depends on:
Blocks: 2563
  Show dependency treegraph
 
Reported: 2010-12-01 05:38 UTC by Bernard Helyer
Modified: 2015-06-09 01:31 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bernard Helyer 2010-12-01 05:38:20 UTC
http://www.digitalmars.com/d/2.0/class.html

Inheritance is defined by the grammar to be allowed to take this form:

    Protection Identifier

However, this is not mentioned anywhere, and the semantics are entirely undefined.
Comment 1 Jonathan M Davis 2010-12-01 10:12:07 UTC
Well, that's exceptionally weird. It compiles too. D doesn't support any kind of inheritance but public. It seems like either it's a hold-over which was never removed (assuming that D supported private or protected inheritance in the past), or it was intended to make porting C++ code easier. But it seems to me that allowing and then ignoring (as the compiler presumably does) protection identifiers when inheriting classes is not good behavior. The fact that the compiler allows it though means that it's more than just a spec issue.
Comment 2 Stewart Gordon 2011-07-24 09:38:50 UTC
Looking at (In reply to comment #1)
> Well, that's exceptionally weird.  It compiles too.  D doesn't 
> support any kind of inheritance but public.  It seems like either 
> it's a hold-over which was never removed (assuming that D supported 
> private or protected inheritance in the past),

According to the description and first comment on issue 177, private/protected inheritance once worked.  But it doesn't work now (1.069, 2.054).  But it never made sense to have the feature in D.

> or it was intended to make porting C++ code easier.

D was never intended to be source-compatible with C++, or even C.  Consequently, such a tiny concession makes no sense at all, and even less sense considering the fundamental differences between C++ classes and D classes.

> But it seems to me that allowing and then ignoring (as the compiler 
> presumably does) protection identifiers when inheriting classes is 
> not good behavior.  The fact that the compiler allows it though 
> means that it's more than just a spec issue.

Issue 177 is "Remove inheritance protection".  Essentially that has been done, but by ignoring attempts to use it rather than making it illegal.  So that issue has been reduced to this one.
Comment 3 Stewart Gordon 2011-07-24 09:44:36 UTC
*** Issue 177 has been marked as a duplicate of this issue. ***
Comment 6 yebblies 2014-08-28 15:16:42 UTC
Pull to turn deprecation message into an error.

https://github.com/D-Programming-Language/dmd/pull/3911
Comment 7 github-bugzilla 2014-08-31 05:23:06 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5ffc7d3784dc416769ff1a4aa0ab959ca42cd47e
Fix Issue 5299 - Protected inheritance is semantically undefined

Deprecation -> Error

https://github.com/D-Programming-Language/dmd/commit/486e92da11fd567c32634a3085a31fa266634d77
Merge pull request #3911 from yebblies/issue5299

Issue 5299 - Turn base class protection into an error