D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3616 - __traits(compiles) returns true for uncompilable code due to static assert
Summary: __traits(compiles) returns true for uncompilable code due to static assert
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-14 10:51 UTC by Lutger
Modified: 2015-06-09 01:27 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 Lutger 2009-12-14 10:51:43 UTC
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 Denis Shelomovskii 2012-01-01 02:37:37 UTC
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.