[Bug c/83433] missing signed integer overflow diagnostic for abs(INT_MIN)
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 18 18:36:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83433
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-01-18
CC| |msebor at gcc dot gnu.org
Summary|Should -Wstrict-overflow=2 |missing signed integer
|produce a diagnostic for |overflow diagnostic for
|abs(INT_MIN) |abs(INT_MIN)
Ever confirmed|0 |1
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
-Woverflow diagnoses a bare negation of INT_MIN and it would be useful to
diagnose the same negation by abs(). The folder folds abs() into the same
expression and it has all the knowledge it needs to diagnose it With that,
confirmed.
$ cat pr83433.c && gcc -O2 -S -Wall -Wextra -Wstrict-overflow=2
-fdump-tree-optimized=/dev/stdout pr83433.c
#define INT_MIN (-__INT_MAX__ - 1)
int f (void)
{
return -INT_MIN;
}
int g (void)
{
return __builtin_abs (INT_MIN);
}
pr83433.c: In function ‘f’:
pr83433.c:5:10: warning: integer overflow in expression ‘-2147483648’ of type
‘int’ results in ‘-2147483648’ [-Woverflow]
return -INT_MIN;
^
;; Function f (f, funcdef_no=0, decl_uid=1950, cgraph_uid=0, symbol_order=0)
f ()
{
<bb 2> [local count: 1073741825]:
return -2147483648;
}
;; Function g (g, funcdef_no=3, decl_uid=1953, cgraph_uid=1, symbol_order=1)
g ()
{
<bb 2> [local count: 1073741825]:
return -2147483648;
}
More information about the Gcc-bugs
mailing list