This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: BUG: assuming signed overflow does not occur when simplifying conditional to constant
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Bruce Korb <bruce dot korb at gmail dot com>
- Cc: GCC <gcc at gcc dot gnu dot org>
- Date: Sat, 29 Dec 2012 11:38:36 +0100
- Subject: Re: BUG: assuming signed overflow does not occur when simplifying conditional to constant
- References: <50DE3564.2020905@gmail.com>
* Bruce Korb:
> I wrote a loop that figures out how many items are in a list,
> counts down from that count to -1, changes direction and counts
> up from 0 to the limit, a la:
>
>
> inc = -1;
> int idx = 0;
> while (opts->papzHomeList[idx+1] != NULL)
> idx++;
> for (;;) {
> if (idx < 0) { <<<=== line 1025
> inc = 1;
> idx = 0;
> }
> char const * path = opts->papzHomeList[ idx ];
> if (path == NULL)
> break;
> idx += inc;
> // do a bunch of stuff
> }
>
> ../../autoopts/configfile.c: In function 'intern_file_load':
> ../../autoopts/configfile.c:1025:12: error: assuming signed overflow does not occur \
> when simplifying conditional to constant [-Werror=strict-overflow]
I can't reproduce this. Can you post a minimal example that actually
shows this warning?
> My guess is that some code somewhere presumes that "idx" never gets
> decremented. Not true.
The warning can trigger after inlining and constant propogation,
somewhat obscuring its cause. PR55616 is one such example.