https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84127
Bug ID: 84127 Summary: pragmas to disable -Wexpansion-to-defined compiler warnings seems to be broken since 7.x Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: davydden at gmail dot com Target Milestone: --- Dear all, Looks like GCC 7.x changed in the way pragmas are processed. Below is a small example which still produces compiler warning -Wexpansion-to-defined: # define DISABLE_EXTRA_DIAGNOSTICS \ _Pragma("GCC diagnostic push") /*!*/ \ _Pragma("GCC diagnostic ignored \"-Wexpansion-to-defined\"") \ # define ENABLE_EXTRA_DIAGNOSTICS \ _Pragma("GCC diagnostic pop") DISABLE_EXTRA_DIAGNOSTICS #define BLA defined(FOO) #if BLA int k=0; #endif ENABLE_EXTRA_DIAGNOSTICS int z = 0; the actual pragmas used in the open-source library are here https://github.com/dealii/dealii/blob/master/include/deal.II/base/config.h.in#L336-L374 and the discussion of this issue in the context of the library is here https://github.com/dealii/dealii/issues/5466#issuecomment-360076509 here's a link to the same example compiled online: https://godbolt.org/g/tAv4yd Regards, Denis.