[libcxx] r209305 - Fix bug 19740; round-tripping a pointer through a stream doesn't work

Marshall Clow mclow.lists at gmail.com
Wed May 21 09:02:20 PDT 2014


Author: marshall
Date: Wed May 21 11:02:20 2014
New Revision: 209305

URL: http://llvm.org/viewvc/llvm-project?rev=209305&view=rev
Log:
Fix bug 19740; round-tripping a pointer through a stream doesn't work

Modified:
    libcxx/trunk/include/locale
    libcxx/trunk/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=209305&r1=209304&r2=209305&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Wed May 21 11:02:20 2014
@@ -1180,11 +1180,11 @@ num_get<_CharT, _InputIterator>::do_get(
             break;
     }
     // Stage 3
-    __a[sizeof(__a)-1] = 0;
+    __buf.resize(__a_end - __a);
 #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    if (sscanf_l(__a, _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
+    if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
 #else
-    if (__sscanf_l(__a, __cloc(), "%p", &__v) != 1)
+    if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1)
 #endif
         __err = ios_base::failbit;
     // EOF checked

Modified: libcxx/trunk/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp?rev=209305&r1=209304&r2=209305&view=diff
==============================================================================
--- libcxx/trunk/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp (original)
+++ libcxx/trunk/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp Wed May 21 11:02:20 2014
@@ -76,4 +76,22 @@ int main()
         assert(!is.eof());
         assert(!is.fail());
     }
+    {
+        testbuf<char> sb("12345678");
+        std::istream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)0x12345678);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L"12345678");
+        std::wistream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)0x12345678);
+        assert( is.eof());
+        assert(!is.fail());
+    }
 }





More information about the cfe-commits mailing list