D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7472 - Cast from class to basic type not rejected during semantic
Summary: Cast from class to basic type not rejected during semantic
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, ice, pull, rejects-valid
Depends on:
Blocks: 7760
  Show dependency treegraph
 
Reported: 2012-02-09 09:55 UTC by timon.gehr
Modified: 2015-06-09 05:11 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-02-09 09:55:47 UTC
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 yebblies 2012-02-09 21:58:52 UTC
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 3 github-bugzilla 2013-12-03 19:48:20 UTC
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 github-bugzilla 2013-12-19 04:24:52 UTC
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