Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Issue 1584203002: Remove undefined behavior from safe_strerror_posix.cc (Closed)

Created:
4 years, 11 months ago by Nico
Modified:
4 years, 11 months ago
Reviewers:
brettw
CC:
chromium-reviews, vmpstr+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -1 line) Patch
M base/posix/safe_strerror.cc View 1 chunk +5 lines, -1 line 0 comments Download

Messages

Total messages: 11 (6 generated)
Nico
imho it's very surprising and annoying that this is undefined behavior, but since compilers do ...
4 years, 11 months ago (2016-01-14 14:43:50 UTC) #2
brettw
lgtm
4 years, 11 months ago (2016-01-15 21:18:48 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1584203002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1584203002/1
4 years, 11 months ago (2016-01-15 21:20:51 UTC) #7
commit-bot: I haz the power
Committed patchset #1 (id:1)
4 years, 11 months ago (2016-01-15 22:49:46 UTC) #9
commit-bot: I haz the power
4 years, 11 months ago (2016-01-15 22:50:37 UTC) #11
Message was sent while issue was closed.
Patchset 1 (id:??) landed as
https://crrev.com/36e38a244f1292bc22c94d0ab13f300fda124cef
Cr-Commit-Position: refs/heads/master@{#369872}

Powered by Google App Engine
This is Rietveld 408576698