[Commits] [wesnoth/wesnoth] e57445: Remove `this` null pointer comparisons
GitHub
noreply at github.com
Thu Oct 30 09:24:54 UTC 2014
Branch: refs/heads/master
Home: https://github.com/wesnoth/wesnoth
Commit: e5744562cc33e7049f55b15f2c1db5d83e84b8f3
https://github.com/wesnoth/wesnoth/commit/e5744562cc33e7049f55b15f2c1db5d83e84b8f3
Author: Ignacio R. Morelle <shadowm at wesnoth.org>
Date: 2014-10-30 (Thu, 30 Oct 2014)
Changed paths:
M src/game_data.hpp
Log Message:
-----------
Remove `this` null pointer comparisons
It appears the standard specifies that `this` being null is undefined
behavior. Compilers may choose to optimize taking UB into account; in
particular, the null pointer check in question can be optimized out.
clang 3.5 has a new warning flag -Wtautological-pointer-compare which
warns against that particular case, among others.
http://llvm.org/releases/3.5.0/tools/clang/docs/ReleaseNotes.html
This fixes the following warnings with clang 3.5:
src/actions/../game_data.hpp:66:5: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
src/actions/../game_data.hpp:74:5: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
src/actions/../game_data.hpp:130:5: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
More information about the Commits
mailing list