digitalmars.D.bugs - [Issue 23530] New: casting immutable away allowed in safe
- d-bugmail puremagic.com (26/26) Dec 01 2022 https://issues.dlang.org/show_bug.cgi?id=23530
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 puremagic.com Reporter: Ajieskola 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. --
Dec 01 2022