public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/92286] Possible improvement for -Wduplicated-cond warning
[not found] <bug-92286-4@http.gcc.gnu.org/bugzilla/>
@ 2022-10-10 18:59 ` dcb314 at hotmail dot com
2022-10-10 19:03 ` dcb314 at hotmail dot com
2022-10-11 8:54 ` marxin at gcc dot gnu.org
2 siblings, 0 replies; 3+ messages in thread
From: dcb314 at hotmail dot com @ 2022-10-10 18:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92286
David Binderman <dcb314 at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dcb314 at hotmail dot com
--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
Is there a simpler case which is worth addressing, where a condition
is a simple opposite of a predecessor ?
Something like:
void f2( int a, int b)
{
if (a < b)
g( a);
else if (a >= b)
g( b);
else
g( a + b);
}
Static analyser cppcheck can find this:
feb23b.cc:20:13: style: Expression is always true because 'else if' condition
is
opposite to previous condition at line 18. [multiCondition]
else if (a >= b)
^
feb23b.cc:18:8: note: first condition
if (a < b)
^
feb23b.cc:20:13: note: else if condition is opposite to first condition
else if (a >= b)
^
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/92286] Possible improvement for -Wduplicated-cond warning
[not found] <bug-92286-4@http.gcc.gnu.org/bugzilla/>
2022-10-10 18:59 ` [Bug c/92286] Possible improvement for -Wduplicated-cond warning dcb314 at hotmail dot com
@ 2022-10-10 19:03 ` dcb314 at hotmail dot com
2022-10-11 8:54 ` marxin at gcc dot gnu.org
2 siblings, 0 replies; 3+ messages in thread
From: dcb314 at hotmail dot com @ 2022-10-10 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92286
--- Comment #5 from David Binderman <dcb314 at hotmail dot com> ---
A quick grep suggests two problems in gcc source code:
trunk.git/gcc/ada/sysdep.c:423:26: style: Expression is always true because
'else if' condition is opposite to previous condition at line 415.
[multiCondition]
trunk.git/libsanitizer/sanitizer_common/sanitizer_allocator_primary64.h:547:27:
style: Expression is always true because 'else if' condition is opposite to
previous condition at line 538. [multiCondition]
and 34 cases in the linux-6.0 kernel.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/92286] Possible improvement for -Wduplicated-cond warning
[not found] <bug-92286-4@http.gcc.gnu.org/bugzilla/>
2022-10-10 18:59 ` [Bug c/92286] Possible improvement for -Wduplicated-cond warning dcb314 at hotmail dot com
2022-10-10 19:03 ` dcb314 at hotmail dot com
@ 2022-10-11 8:54 ` marxin at gcc dot gnu.org
2 siblings, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-11 8:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92286
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
> trunk.git/libsanitizer/sanitizer_common/sanitizer_allocator_primary64.h:547:
> 27: style: Expression is always true because 'else if' condition is opposite
> to previous condition at line 538. [multiCondition]
This one is correct, but the code assumes there's no fallback edge:
...
} else if (chunk_size > page_size) {
// One chunk covers multiple pages, Some chunks are crossing page
// boundaries. Some pages contain one chunk, some contain two.
full_pages_chunk_count_max = 2;
same_chunk_count_per_page = false;
} else {
UNREACHABLE("All chunk_size/page_size ratios must be handled.");
}
Thus I'm going to leave it.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-11 8:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-92286-4@http.gcc.gnu.org/bugzilla/>
2022-10-10 18:59 ` [Bug c/92286] Possible improvement for -Wduplicated-cond warning dcb314 at hotmail dot com
2022-10-10 19:03 ` dcb314 at hotmail dot com
2022-10-11 8:54 ` marxin at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).