D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9669 - Throw in a pre-condition of a nothrow function
Summary: Throw in a pre-condition of a nothrow function
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2013-03-08 12:12 UTC by bearophile_hugs
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-03-08 12:12:26 UTC
This code compiles with dmd 2.063alpha:


void foo() nothrow
in {
    throw new Exception(null);
} body {
}
void main() {
    foo();
}



Then it throws at runtime:

object.Exception@test.d(3)
---------
0x00402044 in nothrow void test.foo() at ...
...


I think that's bad because I think the "nothrow" tag used by the compiler to better optimize functions.