Bug 10345 – Segfault on simple main() with -release

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-12T11:50:00Z
Last change time
2013-06-12T11:57:56Z
Assigned to
nobody
Creator
justin

Comments

Comment #0 by justin — 2013-06-12T11:50:17Z
Using dmd 2.063: void main() { assert(false, "Uhoh"); } Compiling with -release and running segfaults (tested on linux). Compiling without -release and running produces the expected AssertError. Expected behavior with -release is an effectively empty main(). Examining the core dump: ----------------------------------------------- Core was generated by `./test_assert'. Program terminated with signal 11, Segmentation fault. #0 D main () at test_assert.d:3 3 assert(false, "Uhoh"); (gdb) bt #0 D main () at test_assert.d:3 #1 0x0000000000417e00 in rt.dmain2._d_run_main() () #2 0x0000000000417932 in rt.dmain2._d_run_main() () #3 0x0000000000417e50 in rt.dmain2._d_run_main() () #4 0x0000000000417932 in rt.dmain2._d_run_main() () #5 0x00000000004178ee in _d_run_main () #6 0x000000000041773b in main () -----------------------------------------------
Comment #1 by code — 2013-06-12T11:53:44Z
assert(false) is turned into a halt/abort in release mode.
Comment #2 by justin — 2013-06-12T11:57:56Z
My bad. This special case is documented here: http://dlang.org/expression.html#AssertExpression