فهرست منبع

add a test and a couple minor bug fixes for the implicit-signed-integer-truncation sanitizer. This is PR#40566

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@352926 91177308-0d34-0410-b5e6-96231b3b80d8
Marshall Clow 6 سال پیش
والد
کامیت
5d83dada72
3فایلهای تغییر یافته به همراه7 افزوده شده و 2 حذف شده
  1. 1 1
      include/locale
  2. 1 1
      include/sstream
  3. 5 0
      test/std/input.output/string.streams/stringstream.members/str.pass.cpp

+ 1 - 1
include/locale

@@ -546,7 +546,7 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
         __exp = 'P';
     else if ((__x & 0x5F) == __exp)
     {
-        __exp |= 0x80;
+        __exp |= (char) 0x80;
         if (__in_units)
         {
             __in_units = false;

+ 1 - 1
include/sstream

@@ -558,7 +558,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
             char_type* __p = const_cast<char_type*>(__str_.data());
             this->setg(__p, __p + __ninp, __hm_);
         }
-        return this->sputc(__c);
+        return this->sputc(traits_type::to_char_type(__c));
     }
     return traits_type::not_eof(__c);
 }

+ 5 - 0
test/std/input.output/string.streams/stringstream.members/str.pass.cpp

@@ -58,4 +58,9 @@ int main()
         ss << i << ' ' << 321;
         assert(ss.str() == L"89 3219 ");
     }
+    {
+        std::stringstream ss;
+        ss.write("\xd1", 1);
+        assert(ss.str().length() == 1);
+    }
 }