[Issue 23767] New: ImportC: ternary with null constant has wrong pointer type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 9 15:59:38 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23767
Issue ID: 23767
Summary: ImportC: ternary with null constant has wrong pointer
type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P4
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
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
```
--
More information about the Digitalmars-d-bugs
mailing list