Bug 23134 – Mutate variable through immutable pointer

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2022-05-24T17:33:55Z
Last change time
2024-12-13T19:23:04Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: dmd#20111 →

Comments

Comment #0 by bugzilla — 2022-05-24T17:33:55Z
As reported by deadalnix: ```d struct S { void delegate() dg; } void main() { int x = 42; immutable S s = { dg: () { x++; } }; s.dg(); import std.stdio; writeln(x); } ``` This still compiles and run and mutates a variable through an immutable pointer. This variable could be shared too because immutable is safe to share. May be related to https://issues.dlang.org/show_bug.cgi?id=16095 and https://issues.dlang.org/show_bug.cgi?id=1983
Comment #1 by dlang-bot — 2022-05-25T07:08:51Z
@WalterBright created dlang/dmd pull request #14164 "fix Issue 23134 - Mutate variable through immutable pointer" fixing this issue: - fix Issue 23134 - Mutate variable through immutable pointer https://github.com/dlang/dmd/pull/14164
Comment #2 by robert.schadek — 2024-12-13T19:23:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20111 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB