two examples, i think they're the same bug // test1.c int printf(char *, ...); int main() { int a = 0; // dmd gives 1, other compilers -1 // bug disappears if the parentheses around (a) are removed int b = - (a) - 1; printf("%d\n", b); } // test2.c int example2() { int *a, *b; // Error: incompatible types for `(a) - (cast(char*)b)`: `int*` and `char*` // works if the parentheses around (a) are removed long diff = (char*)(a) - (char*)b; }
one more example that i forgot to add: void fn() { int *p; // Error: `p` is not of integral type, it is a `int*` // Error: `cast(int*)1` is not of integral type, it is a `int*` // works if parentheses around (p) are removed unsigned x = (unsigned)(p) & 1; } there's no ambiguous cast in this one so i've changed the issue title to something that should apply to all the examples
@WalterBright created dlang/dmd pull request #13831 "fix Issue 22876 - importC: expression parsing affected by parentheses…" fixing this issue: - fix Issue 22876 - importC: expression parsing affected by parentheses that should do nothing https://github.com/dlang/dmd/pull/13831
dlang/dmd pull request #13831 "fix Issue 22876 - importC: expression parsing affected by parentheses…" was merged into master: - b25875b21fdd855b403a2254feb29b1b3385a795 by Walter Bright: fix Issue 22876 - importC: expression parsing affected by parentheses that should do nothing https://github.com/dlang/dmd/pull/13831