www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7472] New: __traits compiles/ is(typeof) don't work for invalid type casts.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7472

           Summary: __traits compiles/ is(typeof) don't work for invalid
                    type casts.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



DMD 2.057 and 2.058head

void main(){
    class X{} X    x;
    static assert(!__traits(compiles, cast(int)x));// assertion failure
    int y = cast(int)x;                            // compile error
}

Apparently casts are checked for validity too late.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 09 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7472


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |yebblies gmail.com
            Version|D2                          |D1 & D2



This happens because only some checking of casts is done in the frontend, the
rest is done in the glue layer. (e2ir.c CastExp::toElem)

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