Bug 3616 – __traits(compiles) returns true for uncompilable code due to static assert

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-12-14T10:51:00Z
Last change time
2015-06-09T01:27:02Z
Assigned to
nobody
Creator
lutger.blijdestijn

Comments

Comment #0 by lutger.blijdestijn — 2009-12-14T10:51:43Z
void foo() { static assert(false); } void main() { static assert( __traits(compiles, foo()) == false ); } The assert fails, but should not. Looks similar to bug 3448.
Comment #1 by verylonglogin.reg — 2012-01-01T02:37:37Z
Assertion in `foo` should fail because `foo` is a regular function and compiles independently of assertion in `main`. This code compiles: --- void foo()() { static assert(false); } void main() { static assert(!__traits(compiles, foo!()())); } --- Note, that due to bug 3448 __traits(compiles) works correctly only if it is in a function.