Bug 21509 – alloca and exceptions causes wrong code.

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-12-27T13:02:13Z
Last change time
2024-12-13T19:13:41Z
Assigned to
No Owner
Creator
John Colvin
Moved to GitHub: dmd#18011 →

Comments

Comment #0 by john.loughran.colvin — 2020-12-27T13:02:13Z
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!
Comment #1 by robert.schadek — 2024-12-13T19:13:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18011 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB