Bug 23767 – ImportC: ternary with null constant has wrong pointer type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-03-09T15:59:38Z
Last change time
2023-03-16T01:20:58Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2023-03-09T15:59:38Z
In a C ternary expression, when one expression is a pointer and the other is the null pointer constant, the resulting type should be the pointer. This compiles with GCC: ``` int arr[4]; void f(void) { int x = *(0 ? (void*)0 : arr); } ``` But with ImportC, it considers the type a void pointer and errors with: ``` Error: expression `*(0 ? cast(void*)0 : &arr)` is `void` and has no value ```
Comment #1 by dlang-bot — 2023-03-10T15:48:00Z
@dkorpel created dlang/dmd pull request #14980 "Fix 23767 - ImportC: ternary with null constant has wrong pointer type" fixing this issue: - Fix 23767 - ImportC: ternary with null constant has wrong pointer type https://github.com/dlang/dmd/pull/14980
Comment #2 by dlang-bot — 2023-03-13T09:23:46Z
dlang/dmd pull request #14980 "Fix 23767 - ImportC: ternary with null constant has wrong pointer type" was merged into stable: - b124cf909e55cb6415801485783edfec07344b00 by Dennis Korpel: Fix 23767 - ImportC: ternary with null constant has wrong pointer type https://github.com/dlang/dmd/pull/14980
Comment #3 by dlang-bot — 2023-03-16T01:20:58Z
dlang/dmd pull request #14992 "merge stable" was merged into master: - fc3517e7a05c3086df714b5048ee0ea73d9084eb by Dennis: Fix 23767 - ImportC: ternary with null constant has wrong pointer type (#14980) https://github.com/dlang/dmd/pull/14992