[Bug c/64279] New: Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 12 08:50:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64279
Bug ID: 64279
Summary: Warning missing for "(cond) ? A : A" / if(cond) expr1;
else expr1; // same expression in if and else branch
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: mpolacek at gcc dot gnu.org
Related to PR63357 but for the branch and not for the condition.
In a real-world code, cppcheck detected: "Found duplicate branches for 'if' and
'else'.":
if (_perimeter >= ci.perimeter)
_perimeter -= ci.perimeter;
else
_perimeter -= ci.perimeter;
It would be nice if GCC could also detect those - at least when both branches
consist only of a simple statement - and similarly for "(cond) ? a : a".
More information about the Gcc-bugs
mailing list