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.
Comment #1 by yebblies — 2012-02-09T21:58:52Z
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)