Fix 23767 - ImportC: ternary with null constant has wrong pointer type#14980
Fix 23767 - ImportC: ternary with null constant has wrong pointer type#14980RazvanN7 merged 1 commit intodlang:stablefrom
Conversation
|
Thanks for your pull request and interest in making D better, @dkorpel! 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 references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + dmd#14980" |
| // https://issues.dlang.org/show_bug.cgi?id=23767 | ||
| // `cast(void*) 0` should be treated as `null` so the ternary expression | ||
| // gets the pointer type of the other branch | ||
| if (sc.flags & SCOPE.Cfile) |
There was a problem hiding this comment.
Is there a way to change the way the types are merged rather than rewriting them? Not sure if you have the scope available but you could always just have a different function for finding the common types of C.
The C behaviour (in a sense) was almost what D used to do before I fixed it a while back.
There was a problem hiding this comment.
void* + T* merges to void* in general, both in C and D, only in C there is special treatment when the void* is the NULL constant
There was a problem hiding this comment.
Previously it went to T* until I fixed it (I think ldc 1.30 still has this bug)
Could potentially use TypeNull
There was a problem hiding this comment.
I am rewriting (void*)0 to use TypeNull
No description provided.