[Issue 23530] New: casting immutable away allowed in safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 1 16:42:21 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23530
Issue ID: 23530
Summary: casting immutable away allowed in safe
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: Ajieskola at gmail.com
The following code compiles and runs without crash with DMD 2.100.2, flags
-preview=dip1000:
------
@safe void main()
{ immutable int x = 5; //alternatively const
auto a = &x;
auto b = &cast() x;
assert(a == b); //passes
*b = 3; //undefined behaviour
}
------
This is a major hole in memory safety, so I'm assigning severity to critical.
--
More information about the Digitalmars-d-bugs
mailing list