1 #include <upc.h>
2 int main(void) {
3 shared int *p;
4 int i;
5
6 int a = p ? 0 : 1;
7 int b = (p && i) ? 0 : 1;
8
9 return 0;
10 }
Clang-upc2c is translating lines 6 and 7 as
int a = !upcr_isnull_pshared(p) ? 0 : 1;
int b = (p && i) ? 0 : 1;
The translation of line 6 (initialization of a) correctly uses upcr_isnull_pshared().
However, no such conversion is being applied in the translation of line 7.
This mistranslation goes unnoticed with a packed representation of the pointer-to-shared, but is still incorrect because there are NULL pointers-to-shared that are not zero (non-zero phase in particular).
In the case of a struct representation of the pointer-to-shared, the mistranslation leads to a compilation error from the backend, since struct && int is not a valid expression.
Given the following UPC input:
Clang-upc2c is translating lines 6 and 7 as
The translation of line 6 (initialization of
a
) correctly usesupcr_isnull_pshared()
. However, no such conversion is being applied in the translation of line 7.This mistranslation goes unnoticed with a packed representation of the pointer-to-shared, but is still incorrect because there are NULL pointers-to-shared that are not zero (non-zero phase in particular).
In the case of a struct representation of the pointer-to-shared, the mistranslation leads to a compilation error from the backend, since
struct && int
is not a valid expression.