[Issue 6732] New: static assert fails on true expression
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 26 09:14:50 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6732
Summary: static assert fails on true expression
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-09-26 09:14:17 PDT ---
template isDouble(T) {
enum bool isDouble = __traits(hasMember, T, "x") || is(T == double);
}
void test(T)(T rhs) if (is(T == int)) { }
void test(T)(T rhs) if (isDouble!T) { }
void main()
{
static assert(__traits(compiles, test(4.5))); // fail
test(4.5); // fine
}
If you comment out the static assert you'll see that the test() call compiles.
Oddly enough if you swap the order of the calls like so:
void main()
{
test(4.5);
static assert(__traits(compiles, test(4.5)));
}
Then it works again.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list