March 09, 2023 [Issue 23767] New: ImportC: ternary with null constant has wrong pointer type | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: dkorpel@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 ``` -- |
Copyright © 1999-2021 by the D Language Foundation