This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Request to merge Undefined Behavior Sanitizer in


On 07/26/2013 01:33 AM, Andrew Pinski wrote:
What does it mean by "unsigned-integer-overflow"? Unsigned integers
never overflow.

This is a common misconception. Conversion to an unsigned integer type never has undefined behavior, but unsigned integer arithmetic does. C11 says,

If an exceptional condition occurs during the evaluation of an expression (that is, if the result is not mathematically defined or not in the range of representable values for its type), the behavior is undefined.

So UINT_MAX+1U has undefined behavior.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]