Chromium Code Reviews
DescriptionRemove undefined behavior from safe_strerror_posix.cc
[cpp.cond]p4:
Prior to evaluation, macro invocations in the list of preprocessing
tokens that will become the controlling constant expression are replaced
(except for those macro names modified by the 'defined' unary operator),
just as in normal text. If the token 'defined' is generated as a result
of this replacement process or use of the 'defined' unary operator does
not match one of the two specified forms prior to macro replacement, the
behavior is undefined.
This isn't an idle threat, consider this program:
#define FOO
#define BAR defined(FOO)
#if BAR
...
#else
...
#endif
clang and gcc will pick the #if branch while Visual Studio will take the
#else branch.
This works fine in this file since it's not built on Windows, but relying
on that seems a bit risky.
(I'm prototyping a compiler warning for this -- not sure yet a compiler warning
is worth it, but fixing this file is.)
No behavior change.
BUG=428589
Committed: https://crrev.com/36e38a244f1292bc22c94d0ab13f300fda124cef
Cr-Commit-Position: refs/heads/master@{#369872}
Patch Set 1 #
Messages
Total messages: 11 (6 generated)
|
|||||||||||||||||||