www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6732] New: static assert fails on true expression

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



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: -------
Sep 26 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6732


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |
            Summary|__traits(compiles) fails on |ICE: __traits(compiles)
                   |valid expression            |fails on valid expression



06:55:23 PST ---
The following has now turned into an ICE (is a crash equivalent to an ICE?) in
2.057:

template isDouble(T) 
{
    enum bool isDouble = __traits(hasMember, T, "x");
}

void test(T)(T rhs) if (isDouble!T) { }

void main() 
{
    test(4.5);
}

---------------------------
dmd.exe - Application Error
---------------------------
The instruction at "0x00489e61" referenced memory at "0x00000000". The memory
could not be "read".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6732


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED






Finally this issue was completely fixed in 2.058head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2012