[Issue 2618] New: Assert errors should be unrecoverable.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 25 19:44:46 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2618

           Summary: Assert errors should be unrecoverable.
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: dsimcha at yahoo.com


void main() {
    foo(1);
}

void foo(int i) nothrow {
    assert(i < 0);
    return i;
}

Compiles in release mode because asserts are disabled.  When asserts are
enabled, compilation fails w/ the following error msg:

test.d|5|function test.foo 'foo' is nothrow yet may throw

Fixing this is necessary to allow some code that doesn't throw any "real"
exceptions, but uses asserts for internal consistency checks, to compile in
debug mode.  Also, if asserts are used in the precondition block instead of in
the body, then the code compiles:

void foo(int i) nothrow
in {
    assert(i < 0);
} body {
    return i;
}


-- 



More information about the Digitalmars-d-bugs mailing list