https://issues.dlang.org/show_bug.cgi?id=20461
Issue ID: 20461
Summary: [dip1000] Passing stack allocated string to `assert`
compiles
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
This code compiles with DMD 2.089.0 with the `-dip1000` flag:
void main() @safe
{
char[10] buffer = "0123456789";
assert(false, buffer[]);
}
Running this code will obviously assert, but the assert message contains
garbage. The issue is that a stack allocated string has been passed to `assert`
and the assertion message is printed after the stack of `main` is gone. DIP1000
should be able to catch this.
--