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: unassignedclangb...@nondot.org
          Reporter: eugeni.stepa...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to