[Bug other/59545] Signed integer overflow issues

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 20 08:50:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59545

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Markus Trippelsdorf from comment #5)
> Thanks Jakub, it looks much better now. What is left are mostly left shifts
> of negative values:
> 
> gcc/combine.c:11865:14: runtime error: left shift of negative value -4096

Left shifts of negative value we apparently only warn for C++11 and C++14, not
for C++98 (is that because the C++98 wording is fuzzy, don't remember), and for
C99 and C11 the even stronger check where for signed left shifts not only all
negative values shifted up by any amount are invalid, but also positive values
shifted up such that the result is negative or any bits are shifted away.

Perhaps we should fix that in preparation for C++11 anyway, just trying to
understand why GCC hasn't reported it.

> gcc/cp/error.c:448:7: runtime error: call to function
> pp_cxx_type_specifier_seq(cxx_pretty_printer*, tree_node*) through pointer
> to incorrect function type 'void (*)(c_pretty
> _printer *, tree_node *)'

Haven't seen this error, perhaps we don't instrument it (yet)?  Marek?

> gcc/cselib.c:1121:43: runtime error: signed integer overflow: 4224 +
> 9223372036854775806 cannot be represented in type 'long'
> gcc/cselib.c:1121:43: runtime error: signed integer overflow: 4224 +
> 9223372036854775807 cannot be represented in type 'long'
> gcc/expr.c:3986:17: runtime error: signed integer overflow: 0 -
> -9223372036854775808 cannot be represented in type 'long'

I wonder why I haven't seen these with GCC (for clang I used some random svn
snapshot and the compiler was so terribly slow and occassionally hanging that I
gave up on it).  What exact configuration you've used?



More information about the Gcc-bugs mailing list