This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: assuming signed overflow does not occur
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Bruce Korb <bruce dot korb at gmail dot com>
- Cc: GCC List <gcc at gcc dot gnu dot org>
- Date: Sun, 03 Sep 2017 22:48:43 +0200
- Subject: Re: assuming signed overflow does not occur
- Authentication-results: sourceware.org; auth=none
- References: <CAKRnqNLoCO9-JAPisPKKjkM33A_iNeo7yCTJU-AOZtW0vjuDhQ@mail.gmail.com>
* Bruce Korb:
> I know about all these theoretical possibilities of numbers behaving
> in strange ways when arithmetic optimizations assume that signed
> overflow won't occur when they actually might. Yep, it creates subtle
> bugs. The warning is worthwhile. Still and all:
>
> 485 tvdiff = abs_tval(sub_tval(timetv, tvlast));
> 486 if (tvdiff.tv_sec != 0) {
>
> systime.c: In function 'step_systime':
> systime.c:486:5: warning: assuming signed overflow does not occur when
> simplifying conditional to constant [-Wstrict-overflow]
>
> What possible optimization might be going on to cause an overflow
> problem when I simply want to know if the "tv_sec" field is zero or
> not? (BTW, in current source, "tvdiff" is a structure that is returned
> by abs_tval())
This usually happens after inlining and other optimizations. You'll
have to look at GIMPLE dumps to figure out what is going on.
(This is more a question for the gcc-help list.)