[Bug analyzer/98447] incorrect -Wanalyzer-shift-count-overflow warning
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Sat Dec 26 18:17:04 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98447
--- Comment #2 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Note: The warning occurs when the compiler knows that b < 63 in the "if" case
(it occurs up to "n = r % 64", but not with "n = r % 65") so that the condition
"b + 1 >= 64" is always false. I suppose that the p[i--] line has already been
simplified to something equivalent to
p[i--] = 1UL << (b + 1);
but the analyzer doesn't see that b has restricted values in the "if" case.
if (n > b)
{
p[i--] = 1UL << (b + 1);
b += 64;
}
triggers the warning, but not
if (63 > b)
{
p[i--] = 1UL << (b + 1);
b += 64;
}
More information about the Gcc-bugs
mailing list