[Webkit-unassigned] [Bug 160565] Undefined behavior in StdLibExtras.h, bitCount

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Aug 5 09:05:57 PDT 2016


Jonathan Bedard <jbedard at apple.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan Bedard <jbedard at apple.com> ---
Here is the error message clang's undefined behavior sanitizer emits for this particular error:

/Volumes/Data/Code/UndefinedBehavior/OpenSource/WebKitBuild/Debug/usr/local/include/wtf/StdLibExtras.h:163:48: runtime error: unsigned integer overflow: 1025 * 16843009 cannot be represented in type 'unsigned int'

Further investigation on this has revealed that clang is combining some 'suspicious' behaviors with 'undefined' behaviors, and this is a case of 'suspicious' behavior, but, as per C++ 2014 standard 3.9.1, 4, unsigned types overflow with modulo 2^n, which is our desired behavior in this case.  In short, the behavior corrected here is both defined and desired.

Undefined behavior sanitizer information: http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

C++ standard:

No fix is needed.  Marking as resolved.

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160805/cf72e2a2/attachment.html>

More information about the webkit-unassigned mailing list