Bug 19533 – "alias this" prevents "cast(void*)"

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-12-31T17:28:12Z
Last change time
2023-04-25T13:52:21Z
Assigned to
No Owner
Creator
Victor Porton

Comments

Comment #0 by porton — 2018-12-31T17:28:12Z
The following program does not compile. I assume it should compile. --- struct BNode { } class UserObject { BNode record; alias record this; void* context() { return cast(void*)this; } } --- $ dlang.dmd -c test.d test.d(5): Error: cannot cast expression this.record of type BNode to void* $ dlang.dmd --version DMD64 D Compiler v2.083.1
Comment #1 by razvan.nitu1305 — 2023-04-25T13:52:21Z
This seems to have been fixed, I cannot reproduce the error message, however, note that alias this for classes has been deprecated: test.d(5): Deprecation: alias this for classes/interfaces is deprecated