On Fri, 24 Mar 2006, Eric Botcazou wrote: > After the change it is simplified to (int)((unsigned int)j + (unsigned int)o). > Now take j=0 and o=-1. There is signed-overflow undefinedness neither in the > original expression nor in the original simplified expression while there is > in the new simplified expression when UINT_MAX is cast to int.
Conversion of unsigned to int does not involve undefined behavior, it involves implementation-defined behavior, which GCC defines in implement-c.texi: @item @cite{The result of, or the signal raised by, converting an integer to a signed integer type when the value cannot be represented in an object of that type (C90 6.2.1.2, C99 6.3.1.3).} For conversion to a type of width @math{N}, the value is reduced modulo @math{2^N} to be within range of the type; no signal is raised. This is of course a definition of C semantics rather than tree semantics, but I believe our trees follow the C semantics here. -- Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/ [EMAIL PROTECTED] (personal mail) [EMAIL PROTECTED] (CodeSourcery mail) [EMAIL PROTECTED] (Bugzilla assignments and CCs)