Bug 16095 – a delegate can mutate immutable data and break shared / non-shared enforcements

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-30T09:44:07Z
Last change time
2022-05-24T18:10:43Z
Keywords
accepts-invalid, pull, safe
Assigned to
No Owner
Creator
gmanev72
See also
https://issues.dlang.org/show_bug.cgi?id=1983

Comments

Comment #0 by gmanev72 — 2016-05-30T09:44:07Z
the following code shows how one could mutate an immutable object: struct Foo { bool flag; void flip() { flag = true; } } immutable Foo foo; (&foo.flip)(); assert(!foo.flag); //fails
Comment #1 by hbaelx — 2016-07-27T22:41:28Z
It doesn't only break immutability, but also TLS: struct Foo { void ping() shared {} } void main() { Foo a; // a.ping(); // rejected (&a.ping)(); // accepted } I really hope someone fixes this soon enough. This is a major flaw.
Comment #2 by bugzilla — 2016-08-27T05:26:32Z
Comment #3 by github-bugzilla — 2016-08-27T10:42:56Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3c53a0fd9ed1b40f8dbeb75b4dfa11f6df5b3062 fix Issue 16095 - a delegate can mutate immutable data and break shared / non-shared enforcements https://github.com/dlang/dmd/commit/d4f45f99eb250e17dc4bb189ae5440f134731c61 Merge pull request #6091 from WalterBright/fix16095 fix Issue 16095 - a delegate can mutate immutable data and break shar…
Comment #4 by github-bugzilla — 2016-10-01T11:48:36Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3c53a0fd9ed1b40f8dbeb75b4dfa11f6df5b3062 fix Issue 16095 - a delegate can mutate immutable data and break shared / non-shared enforcements https://github.com/dlang/dmd/commit/d4f45f99eb250e17dc4bb189ae5440f134731c61 Merge pull request #6091 from WalterBright/fix16095
Comment #5 by destructionator — 2016-10-06T03:10:55Z
Comment #6 by bugzilla — 2022-05-24T18:10:43Z
(In reply to Adam D. Ruppe from comment #5) > The fix created a new bug... see my comment here > > https://github.com/dlang/dmd/commit/ > 3c53a0fd9ed1b40f8dbeb75b4dfa11f6df5b3062#commitcomment-19312704 Please file bug reports on bugzilla, not on github.