[llvm-bugs] [Bug 25580] New: UBSan detects signed integer overflow for multiplication of uint16_t

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 19 15:46:43 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25580

            Bug ID: 25580
           Summary: UBSan detects signed integer overflow for
                    multiplication of uint16_t
           Product: new-bugs
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: slingn at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 15317
  --> https://llvm.org/bugs/attachment.cgi?id=15317&action=edit
simple test case demonstrating the failure

First seen as a failing test for the SaturatingMultiply() function template
added in r253497.

Test case attached.

$ clang++ -O1 -std=c++11 -fsanitize=undefined test.cpp -o test
$ ./test
main.cpp:25:11: runtime error: signed integer overflow: 65535 * 65535 cannot be
represented in type 'int'

Interestingly, the failure only occurs with uint16_t.
The other unsigned types (uint8_t/uint32_t/uint64_t) pass if I comment out the
uint16_t case.


The issue reproduces at least with clang 3.6 on Ubuntu 15.10 x86_64 as well as
trunk Mac OS X 10.11.1 / Xcode 7.1.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151119/6f9cdaff/attachment.html>


More information about the llvm-bugs mailing list