Bug 19380 – Access through nested struct's .init does not segfault

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2018-11-09T04:12:34Z
Last change time
2024-12-13T19:01:17Z
Assigned to
No Owner
Creator
Stanislav Blinov
Moved to GitHub: dmd#19507 →

Comments

Comment #0 by stanislav.blinov — 2018-11-09T04:12:34Z
Perhaps not the title you'd expect on an issue tracker, but hopefully the code makes it clear: ``` void main() { int x; struct S { void foo() { x++; // nested, accessing main's frame } } assert(S.init.tupleof[$-1] is null); // if the above assertion passes, how come this doesn't segfault?.. S.init.foo(); // A import std.stdio; writeln("You shouldn't be here... ", x); // compared to: S s = S.init; assert(s.tupleof[$-1] is null); s.foo(); // B } ``` It does (correctly?) segfault on A when compiled with LDC, but only on B with DMD.
Comment #1 by robert.schadek — 2024-12-13T19:01:17Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19507 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB