https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129242
Bug ID: 129242
Summary: Proposal: Follow clang in not requiring (though still
allowing) #undef FOO after #pragma push_macro FOO
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: pskocik at gmail dot com
Target Milestone: ---
Currently on gcc
#define FOO 100
#pragma push_macro("FOO")
//#undef FOO
#define FOO 9999
requires the `#undef FOO` after the `#pragma push_macro("FOO")` or else you get
a redefinition warning.
Clang seems to never have required this (while still generating redefinition
warnings if macros are redefined without an intervening push_macro).
I think GCC should follow clang on this and stop requiring the #undef following
a macro push. There's no reason to issue `#pragma push_macro("FOO")` except to
redefine FOO, so nobody should ever need to be saved from an accidental FOO
redefinition if it follows a `#pragma push_macro("FOO")`.
https://godbolt.org/z/6qrn4YxnW