[Issue 9149] Disallow converting delegates to const

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 25 05:56:58 PDT 2016


--- Comment #9 from timon.gehr at gmx.ch ---
(In reply to Sobirari Muhomori from comment #7)
> (In reply to timon.gehr from comment #0)
> > Reading a mutable delegate out of a const reference
> For there to be mutable data accessible through a const reference, the const
> qualifier should not be transitive?
What I meant there is that the type of the field is a mutable delegate type
(and hence it could in principle contain a mutable delegate), which is accessed
through a const 'this' reference.

The issue is that transitivity of const is currently broken for delegate types.
The access must be banned in order to ensure mutable data is not accessible
through a const reference. Otherwise delegates provide a backdoor for
converting const data back to mutable. (I don't think this is much of an issue,
but the designed semantics are that const should be transitive.)


More information about the Digitalmars-d-bugs mailing list