[cfe-commits] r126816 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/integer-overflow.c

Frits van Bommel fvbommel at gmail.com
Wed Mar 2 01:32:34 PST 2011

On Wed, Mar 2, 2011 at 2:49 AM, Eli Friedman <eli.friedman at gmail.com> wrote:
> PR9350: increment/decrement of char (and anything else narrower than int)
> can't overflow due to promotion rules; emit a wrapping add for those cases.

The addition may not be able to overflow, but if the result is not
representable in the (signed) character type it's converted to then
"either the result is implementation-defined or an
implementation-defined signal is raised" [C99].
However, I'm not fluent enough in standardese to know whether that
allows a non-wrapping add to be used in this case. Is 'undef' a valid
implementation-defined result?
(Also, I didn't check C89 or any C++ standards)

More information about the cfe-commits mailing list