[Issue 22182] New: importC: Error: expression expected, not `)` when casting pointer with redundant parens.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 5 21:38:08 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22182
Issue ID: 22182
Summary: importC: Error: expression expected, not `)` when
casting pointer with redundant parens.
Product: D
Version: D2
Hardware: x86_64
OS: Mac OS X
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
The following fails to compile:
typedef struct Bar { int x; } Bar;
int foo(Bar* b){
return ((Bar*)(b))->x;
}
int main(){
Bar b = {3};
return foo(&b);
}
The first relevant error is:
bar.c(4): Error: expression expected, not `)`
The `b` in the expression `((Bar*)(b))->x` has a redundant set of parentheses
around it. Removing them it compiles fine.
This pattern comes up a lot in the Python headers.
--
More information about the Digitalmars-d-bugs
mailing list