Bug 14677 – cast correctness not checked inside is(typeof())
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-06-10T16:03:00Z
Last change time
2015-06-11T05:57:12Z
Assigned to
nobody
Creator
public
Comments
Comment #0 by public — 2015-06-10T16:03:11Z
```
void main()
{
void* x;
// Error: e2ir: cannot cast x of type void* to type int[30]
auto y = cast (int[30]) x;
// But this passes
static assert (is(typeof({ auto y = cast(int[30])x; })));
}
```
Looks like correctness of cast is checked after normal semantic phase and thus ignored by `is(typeof())`
Comment #1 by dlang-bugzilla — 2015-06-10T23:22:52Z
*** This issue has been marked as a duplicate of issue 14596 ***
Comment #2 by public — 2015-06-11T05:06:08Z
Vladimir, sorry, but this doesn't look like duplicate to me. Your linked issue was about rejecting legitimate cast. My report is about checking cast correctness at e2ir stage which makes illegal casts accepted inside is(typeof())
Comment #3 by dlang-bugzilla — 2015-06-11T05:09:12Z
Well, this bug is fixed in HEAD, and the pull request which fixed your bug was trying to fix issue 14596. Both are fixed by the check added in DMDFE.
Comment #4 by dlang-bugzilla — 2015-06-11T05:10:08Z
If you wish, you can reopen with the intent of someone making a pull request which explicitly adds your test case to the DMD test suite.
Comment #5 by k.hara.pg — 2015-06-11T05:22:59Z
(In reply to Dicebot from comment #2)
> My report is about checking cast
> correctness at e2ir stage which makes illegal casts accepted inside
> is(typeof())
Very recently, full detection of invalid casts was added into front end (if I don't mistake somethingn) by the PR:
https://github.com/D-Programming-Language/dmd/pull/4691
So now, they can be tested by using is(typeof()) idiom.