------- Additional Comments From joseph at codesourcery dot com 2005-02-11 23:19 ------- Subject: Re: GCC does not disclose parentheses
On Fri, 11 Feb 2005, l_belev at yahoo dot com wrote: > I dont understand what the purpose of -fwrapv is, because the compiler > always knows whether the machine it's currently generating code for, > wraps around the results on arithmetic overflow. > Anyway surely the first consideration applies in this case too, > that is, the transformations could be disabled if they are not applicable. The internal tree structures (GIMPLE) have well-defined mostly machine-independent semantics, which on signed arithmetic overflow follow C, i.e. signed overflow is undefined behavior unless -fwrapv. This means, for example, that ((x * 2)/2) can be optimized to x for signed arithmetic, although it can't for unsigned. Because of the potential for such transformations to be applied to the results of other transformations, it isn't safe to apply any transformation introducing undefined behavior lest some other such transformation use the fact it is undefined in a way that changes the semantics where the original code did not involve undefined behavior. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19912