Hello, members of GCC development team!
I am involved in support of customers who use GCC.
Recently a customer has complaint that gcc-4.1.2
generates an infinite loop for the following program:

  #include <stdio.h>
  extern void f (int);
  int main ()
  {
  char e = 0;
     do
     {
       printf ("--- e = %i\n", e);
     }
     while (++e);
  }

When compiled with -O2 or higher the program prints
0, 1, ..., 128, ... 1000, ... etc.
(Similar behavior is exposed by gcc-4.6.2).

I've explained the customer that by default char is treated
as signed char on our platform and therefore this program 
does not conform ISO C90, as it causes the integer overflow
(undefined behavior). But he was not satisfied.
He argued that the program compiled with gcc-3.4.6 behaves 
"correctly" and now the compiler silently produces an 
incomprehensible code.

IMHO it would be better to issue a warning
when a finite loop is transformed to an infinite one
(as a result of -ftree-vrp).

Best regards,
Nadezhda Vyukova,
Scientific Research Institute of System Analysis,
RAS


Reply via email to