This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: dewar at gnat dot com
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Fri, 14 Feb 03 09:27:41 EST
- Subject: Re: [PATCH] Document arithmetic overflow semantics
However, once you allow an optimizer to back propagate the assumption
that a program has a defined behavior, things may get surprising, and
as you can see from my earlier message, there is a not too far fetched
scenario in which a well meaning implementation could in fact end up
deleting the system disk unintentionally as an indirect consequence of
an uninitialized variable.
I guess the question is what exactly "back propagate" mean in practice. I
think most people agree that doing so *explicitly* is a bad idea and doesn't
produce any optimizations of correct programs in practice.
The issue is in something like my A * 2 / 2 example in C. Technically
speaking, you can view optimizing this to A as doing that back-propagation,
but an alternate way to look at it is to redefine the arithmetic with
"undefined" as a value and allow the simplification to be valid if
certain well-defined behavior on that arithmetic is preserved.