-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Full name of submitter (unless configured in github; will be published with the issue): Jakub Jelinek
Reference (section label): cpp.replace.general
Link to reflector thread (if any):
Issue description:
Admittedly older issue, but more important with P2843R3
https://eel.is/c++draft/cpp.replace.general#9 allows
#define likely(x) x
#define unlikely(a, b) a + bbut does not allow
#undef likely
#undef unlikelySo, code that would want to define likely/unlikely as function-like macro just temporarily, for some part of code, can't then undefine it.
I'm a little bit worried by this not being IFNDR, there is quite a lot of code in the wild which does
#define inline
#define private publicetc. or e.g.
#define inline __inline__ __attribute__((__always_inline__))clang has -Wkeyword-macro warning, but it has been tweaked shortly after introduction, such that it doesn't diagnose #undef on any keyword identifiers, doesn't diagnose
#define for for
#define inline __inline__
#define whilewith rationale that #undef on keywords is not harmful and defining keyword to self or __ prefixed/suffixed or just prefixed versions is common. In GCC I'm trying to implement it without those special cases and just enable it if -pedantic, but still unsure how much code will it break.
Suggested resolution:
At least something like:
names likely and unlikely may be defined as function-like macros or undefined.