[llvm-bugs] [Bug 40566] New: Libc++ is not Implicit Integer Truncation Sanitizer clean

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 1 11:56:18 PST 2019


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

            Bug ID: 40566
           Summary: Libc++ is not Implicit Integer Truncation Sanitizer
                    clean
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

#include <sstream>

int main() {
  std::stringstream ss;
  ss.write("\xd1", 1);
}


with -fsanitize=implicit-signed-integer-truncation gives:

include/c++/v1/sstream:561:28: runtime error: implicit conversion from type
'std::__1::basic_stringbuf<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::int_type' (aka 'int') of value 209 (32-bit,
signed) to type 'std::__1::basic_streambuf<char, std::__1::char_traits<char>
>::char_type' (aka 'char') changed the value to -47 (8-bit, signed)


basic_stringbuf::overflow converts an int, which is the result of char ->
unsigned char -> int conversion, directly to (signed) char.

-- 
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/20190201/b89664d7/attachment.html>


More information about the llvm-bugs mailing list