December 27, 2020 [Issue 21509] New: alloca and exceptions causes wrong code. | ||||
|---|---|---|---|---|
| ||||
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! -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply