https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53871

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to David Binderman from comment #6)
> Derived from the current Linux kernel:
> 
> // i never changes, so the code loops forever.
> 
> extern int f2( int);
> 
> void f1()
> {
>       int i = 0;
> 
>       do {
>               int n = f2( i);
> 
>               if (n < 0 || n > 10)
>                       break;
>       } while (i < 8);
> }
> 
> $ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra dec30b.cc
> $


The above loop is not so obvious an infinite loop at all.  Since f2 is not
declared as pure/const, GCC can think the return value changes without the
argument changing.  So the example in comment #6 is not an obvious example :).

Reply via email to