Bug 4755 – assert(0,"...") error message

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-08-29T08:43:00Z
Last change time
2010-08-29T18:28:13Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-08-29T08:43:06Z
This D2 program: void main() { assert(0, "This is a message"); } With dmd 2.048 prints: object.Error: assert(0) or HLT instruction It doesn't print the line number nor the "This is a message".
Comment #1 by andrej.mitrovich — 2010-08-29T10:50:43Z
assert(0) is special. It's not meant for debugging, it's meant as a "this piece of code should never have been reached, shut down the application", at least in release mode. From TDPL: "In non-release mode, assert(false) does not do anything special, it just throws an AssertError exception" "In release mode assert(false) will always cause a program to stop. There will be no exception, the program will crash by executing the HLT instruction"
Comment #2 by bearophile_hugs — 2010-08-29T18:28:13Z
You are right, thank you. I have erroneously compiled it in release mode. There is no bug here.