[Issue 21509] New: alloca and exceptions causes wrong code.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 27 13:02:13 UTC 2020
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 at puremagic.com
Reporter: john.loughran.colvin at 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!
--
More information about the Digitalmars-d-bugs
mailing list