D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22530 - Explicit cast between classes incorrectly goes through 'alias this' inside CTFE
Summary: Explicit cast between classes incorrectly goes through 'alias this' inside CTFE
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-11-21 03:47 UTC by Boris Carvajal
Modified: 2021-12-14 10:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Boris Carvajal 2021-11-21 03:47:49 UTC
test:

class D { }

class C
{
    D y = new D();
    alias y this;
}

void main()
{
    static assert(cast(D)(new C) is null); // fails

    assert(cast(D)(new C) is null); // runtime version is OK
}
Comment 1 Dlang Bot 2021-11-21 04:05:15 UTC
@BorisCarvajal created dlang/dmd pull request #13332 "Fix Issue 22530 - Explicit cast between classes incorrectly goes through 'alias this' inside CTFE" fixing this issue:

- Fix Issue 22530 - Explicit cast between classes incorrectly goes through 'alias this' inside CTFE

https://github.com/dlang/dmd/pull/13332
Comment 2 Dlang Bot 2021-11-21 13:47:42 UTC
dlang/dmd pull request #13332 "Fix Issue 22530 - Explicit cast between classes incorrectly goes through 'alias this' inside CTFE" was merged into stable:

- fcea221e0be0dc21b1703158718466baae90ed3d by Boris Carvajal:
  Fix Issue 22530 - Explicit cast between classes incorrectly goes through 'alias this' inside CTFE

https://github.com/dlang/dmd/pull/13332
Comment 3 Dlang Bot 2021-12-14 10:34:28 UTC
dlang/dmd pull request #13421 "merge stable" was merged into master:

- 43f1d040d9c94cc582816e977d7cba2838739f0f by Boris Carvajal:
  Fix Issue 22530 - Explicit cast between classes incorrectly goes through 'alias this' inside CTFE (#13332)

https://github.com/dlang/dmd/pull/13421