[Bug c/64440] -Wdiv-by-zero false negative on const variables
chengniansun at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 30 07:53:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64440
--- Comment #2 from Chengnian Sun <chengniansun at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> In C, const int is not a constant expression and -Wdiv-by-zero only warns
> about integer constant expressions.
Thanks for your reply. It seems GCC sometimes does consider "const int" for
other types of warnings (but not for -Wdiv-by-zero). See the following, with
-O3, GCC warns that the left shift count is negative.
$: cat t.c
int f(int a) {
const char c = -4;
return a << c;
}
$: gcc-trunk -Wall -c t.c -O3
t.c: In function ‘f’:
t.c:3:12: warning: left shift count is negative
return a << c;
^
$:
More information about the Gcc-bugs
mailing list