[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GCC optimizes integer overflow: bug or feature?
From: |
Robert Dewar |
Subject: |
Re: GCC optimizes integer overflow: bug or feature? |
Date: |
Tue, 19 Dec 2006 21:15:20 -0500 |
User-agent: |
Thunderbird 1.5.0.8 (Windows/20061025) |
Paul Brook wrote:
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.
Now that's a bit TOO strong a statement, critical optimizations like
register allocation and instruction scheduling will generally not change
the behavior of the program (though the basic decision to put something
in a register will, and *surely* no one suggests avoiding this critical
optimization).
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.
Valid programs is too narrow a set, you really do have to pay attention
to normal usage. I very well remember the Burroughs 5500 compiler, which
took advantage of the stack semantics allowed by the standard, but in
fact virtually all Fortran programs of the era assumed static allocation
since that's what every other compiler did. As a consequence the 5500
Fortran was completely useless, one factor that certainly caused
universities I was aassociated with to avoid this machine.
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.
Yes, absolutely, I agree with that!
- Re: GCC optimizes integer overflow: bug or feature?, (continued)
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Florian Weimer, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Joseph S. Myers, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Florian Weimer, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Denis Vlasenko, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?, Andrew Haley, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Denis Vlasenko, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Paul Brook, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?,
Robert Dewar <=
- Re: GCC optimizes integer overflow: bug or feature?, Andrew Pinski, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- RE: GCC optimizes integer overflow: bug or feature?, Dave Korn, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?, Robert Dewar, 2006/12/19
- Re: GCC optimizes integer overflow: bug or feature?, Mike Stump, 2006/12/20
- RE: GCC optimizes integer overflow: bug or feature?, Dave Korn, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?, Matthew Woehlke, 2006/12/20
- RE: GCC optimizes integer overflow: bug or feature?, Dave Korn, 2006/12/20
- Message not available
- Re: GCC optimizes integer overflow: bug or feature?, Andreas Schwab, 2006/12/20
- Re: GCC optimizes integer overflow: bug or feature?, Matthew Woehlke, 2006/12/20