digitalmars.D.bugs - [Issue 21509] New: alloca and exceptions causes wrong code.
- d-bugmail puremagic.com (31/31) Dec 27 2020 https://issues.dlang.org/show_bug.cgi?id=21509
https://issues.dlang.org/show_bug.cgi?id=21509 Issue ID: 21509 Summary: alloca and exceptions causes wrong code. Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: john.loughran.colvin gmail.com immutable ex = new Exception("fdsa"); void main() { import std.stdio : writeln; import core.stdc.stdlib : alloca; auto a = (cast(long*)alloca(8))[0..1]; try { throw ex; } catch (Exception) { } a[0] = 3; writeln(a[0]); // 3 writeln(*(a.ptr)); // something else, looks like an address of somewhere on the stack? } LDC does the right thing and prints 3 both times. For future readers: please be careful about closing this as "works for me", because it's not a very stable bug. E.g. putting asserts in to check for 3 pass if the writelns aren't there! --
Dec 27 2020