bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC optimizes integer overflow: bug or feature?


From: Paul Brook
Subject: Re: GCC optimizes integer overflow: bug or feature?
Date: Tue, 19 Dec 2006 21:46:38 +0000
User-agent: KMail/1.9.5

> Compiler can optimize it any way it wants,
> as long as result is the same as unoptimized one.

We have an option for that. It's called -O0.

Pretty much all optimization will change the behavior of your program. The 
important distinction is whether that difference is observable in valid 
programs. The whole point of langage standards is that they define what 
constitutes a valid program.

By your definition all writes to vairables must translate into a write to 
memory (for "correct" behavior in multithreaded applications and with signal 
handlers). This implies all variables are effectively volatile.

You can argue that signed overflow is an extension that it's worth supporting 
by default. Other people (eg. those interested in autovectorization) will 
argue that it provides useful optimization opportunities. I don't know which 
of these is better, but either what it's a lot different to saying "never 
change the behavior of any program.

Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]