diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2014-05-21 16:02:20 +0000 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2014-07-29 15:15:06 -0700 |
commit | ab4cbddb646098c4ffeec558ffce3a442169e410 (patch) | |
tree | 862123ff9835b17e9f44f64ac352c1870bb3cace | |
parent | 142f1f3ac6032e21b069934c61a9bfa3c08c6e81 (diff) | |
download | external_libcxx-ab4cbddb646098c4ffeec558ffce3a442169e410.tar.gz external_libcxx-ab4cbddb646098c4ffeec558ffce3a442169e410.tar.bz2 external_libcxx-ab4cbddb646098c4ffeec558ffce3a442169e410.zip |
Fix bug 19740; round-tripping a pointer through a stream doesn't work
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209305 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 854ad932c8926b373d1dab71b440ac79e3293c4c)
-rw-r--r-- | include/locale | 6 | ||||
-rw-r--r-- | test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp | 18 |
2 files changed, 21 insertions, 3 deletions
diff --git a/include/locale b/include/locale index a60e09344..3e87e9f34 100644 --- a/include/locale +++ b/include/locale @@ -1180,11 +1180,11 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, 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 diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp index 5eda96fe6..52b356664 100644 --- a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp +++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp @@ -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()); + } } |