Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 29, 2022 [Issue 18567] immutability hole related to context pointers accessed through const pure methods | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18567 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> --- The code now compiles and prints: ``` 0 0 ``` So `i` does not change anymore, however, the code is still broken in my opinion, as it should not compile. Since `s` is immutable, maybe the context pointer for fun should also be type as immutable? -- |
July 29, 2022 [Issue 18567] immutability hole related to context pointers accessed through const pure methods | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18567 --- Comment #2 from timon.gehr@gmx.ch --- Well, the compiler is just compiling the code differently now (which it can do, as it exhibits UB), the CSE is pretty easy to defeat though: void main(){ int i = 0; struct S{ const(int)* fun()const pure{ return &i; } } immutable S s; static const(int)* foo(immutable(S) s)pure{ return s.fun(); } immutable(int) *pi=foo(s); import std.stdio; writeln(*pi); // 0 i+=1; int x=*pi; writeln(x); // 1 } The problem is that this line compiles: immutable S s; This requires an immutable context pointer, but a mutable one is provided. In general, context pointers should be type checked essentially as if we were passing around explicit pointers. -- |
December 17, 2022 [Issue 18567] immutability hole related to context pointers accessed through const pure methods | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18567 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P2 -- |
December 13 [Issue 18567] immutability hole related to context pointers accessed through const pure methods | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18567 --- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19405 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation