-
-
Notifications
You must be signed in to change notification settings - Fork 668
Fix Issue 22260: Allow casting class to void* when opCast is defined #22306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request and interest in making D better, @Adityazzzzz! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
thewilsonator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case for this
153c45f to
c0a43f7
Compare
|
I have updated the logic to strictly target the regression. The compiler now only ignores opCast if it returns a class (which causes the recursion bug). Valid opCast implementations that return pointers are now respected. |
|
This does not fix the problem. The cast syntax is doing double duty; it can't do both and work correctly. |
|
I see the fundamental conflict here. |
|
It requires language changes to fix properly. There is nothing to do atm. |
Understood. Thanks for the explanation. |
fixes Issue #22260 a regression where casting a class instance to void* failed if the class defined a matching opCast.
#22260
Previously, the compiler would prioritize the user-defined opCast over the built-in pointer cast. If opCast returned the object itself (or any non-pointer type), the compiler would error, making it impossible to obtain the raw memory address needed for operations like core.memory.GC.free.
The Fix: