D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4755 - assert(0,"...") error message
Summary: assert(0,"...") error message
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-29 08:43 UTC by bearophile_hugs
Modified: 2010-08-29 18:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-08-29 08:43:06 UTC
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 Andrej Mitrovic 2010-08-29 10:50:43 UTC
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 bearophile_hugs 2010-08-29 18:28:13 UTC
You are right, thank you. I have erroneously compiled it in release mode. There is no bug here.