www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22781] New: assert escapes reference to expired stack frame

https://issues.dlang.org/show_bug.cgi?id=22781

          Issue ID: 22781
           Summary: assert escapes reference to expired stack frame
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

As of DMD 2.098.1, the following program compiles, runs, and exhibits undefined
behavior:

---
void main()  safe
{
    char[4] message = "oops";
    assert(0, message[]);
}
---

Example output:

---
core.exception.AssertError bug.d(4): P�;�
----------------
??:? _d_assert_msg [0x55583733f7b0]
??:? _Dmain [0x55583733f724]
---

Instead of "oops", a corrupted message is printed.

--
Feb 16 2022