https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94367
Bug ID: 94367 Summary: pragma GCC diagnostics messes up with one line "if" blocks without curly braces Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: romain.geissler at amadeus dot com Target Milestone: --- Hi, It looks like "if" blocks without curly braces cannot be surrounded by pragma diagnostics. It looks like this is a very old issue, gcc 4.6 already seem to have this problem on Compiler Explorer. Clang raises no such error. void f() { if (true) #pragma GCC diagnostic push ; #pragma GCC diagnostic pop else ; } <source>: In function 'void f()': <source>:7:5: error: 'else' without a previous 'if' 7 | else | ^~~~ Compiler returned: 1 Compiler Explorer uses cookies and other related techs to serve you