Bug 7472 – Cast from class to basic type not rejected during semantic

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-09T09:55:00Z
Last change time
2015-06-09T05:11:58Z
Keywords
accepts-invalid, ice, pull, rejects-valid
Assigned to
nobody
Creator
timon.gehr
Blocks
7760

Comments

Comment #0 by timon.gehr — 2012-02-09T09:55:47Z
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)
Comment #2 by yebblies — 2013-11-26T22:15:26Z
Comment #3 by github-bugzilla — 2013-12-03T19:48:20Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d930042fdf0bba5ec43191a9d625264693075732 Fix Issue 7472 - Cast from class to basic type not rejected during semantic https://github.com/D-Programming-Language/dmd/commit/d5d9624f1e629aab1500330bb0891eef554dc9fe Merge pull request #2886 from yebblies/issue7472 Issue 7472 - Cast from class to basic type not rejected during semantic
Comment #4 by github-bugzilla — 2013-12-19T04:24:52Z
Commits pushed to 2.065 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d930042fdf0bba5ec43191a9d625264693075732 Fix Issue 7472 - Cast from class to basic type not rejected during semantic https://github.com/D-Programming-Language/dmd/commit/d5d9624f1e629aab1500330bb0891eef554dc9fe Merge pull request #2886 from yebblies/issue7472