https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118542
Bug ID: 118542 Summary: Split -Wexpansion-to-defined for function vs. object like macros Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: dangelog at gmail dot com Target Milestone: --- -Wexpansion-to-defined is currently enabled by -Wextra (or -pedantic). While there is implementation divergence when expanding object-like macros (notably, GCC/Clang vs. MSVC without the new preprocessor), there actually isn't when expanding function-like macros. Usages like #define HAS(X) (defined(PLATFORM_HAS_ ## X) && (PLATFORM_HAS ## X)) are pretty common and reasonable (cf PR49928): https://gcc.godbolt.org/z/ajceb67rP For this reason, Clang's -Wexpansion-to-defined has two different severities: * it's *always* active for object-like macros (dangerous in portable code); * it's behind -Weverything / -pedantic for function-like macros (not even -Wextra). Would it be reasonable for GCC to do something along the same lines? (Or, even better, to split the warning, so that one can decide to raise/error on object-like macros, and suppress it for function-like.)