This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Nadezhda IvanÐvna Vyukova<niva@niisi.msk.ru> writes:
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.
Tell your customer to use the -fno-strict-overflow option.
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).
Tell your customer to use the -Wstrict-overflow option.
This message might have been better directed to gcc-help@gcc.gnu.org.
I would have no objection to adding a default warning when a finite loop is converted to an infinite loop. It's harder than it sounds, though. It's not like gcc is looking a loop and deciding to make it infinite. It's looking at a branch instruction and deciding that the condition can never be true.
Ian
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |