https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127403
Bug ID: 127403
Summary: Internally surrounding a statement expression with
#pragma's erroneously voids it in C++ mode
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pskocik at gmail dot com
Target Milestone: ---
This example code:
int main(){
return (__extension__({
#pragma GCC diagnostic push
0;
#pragma GCC diagnostic pop
}));
}
compiles in GCC C mode, and on clang in either C or C++ mode, but it fails to
compile in GCC C++ where the statement expression is erroneously treated as
void-typed because of the trailing #pragma. It doesn't matter whether the
trailing #pragma is inserted manually or via _Pragma.
https://godbolt.org/z/M6bvh6Kjd
Such trailing pragmas (one or multiple) should not affect the type of such a
statement expression.