https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128554
Bug ID: 128554
Summary: Bogus -Wshift-count-negative warning for
__builtin_stdc_bit_floor with a zero-valued const
variable
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: diagnostics
Assignee: dmalcolm at redhat dot com
Reporter: yuki.tanaka at defaultcase dot de
Target Milestone: ---
unsigned f(void)
{
const unsigned char c = 0;
return __builtin_stdc_bit_floor(c);
}
With -O2, GCC warns:
warning: left shift count is negative [-Wshift-count-negative]
The source contains no shift operation.
Compiler Explorer:
https://godbolt.org/z/bfTsdYj34