Commit Graph

11 Commits

Author SHA1 Message Date
Peter Collingbourne
4b54e0fc2a libcxx: Fix for basic_stringbuf::seekoff() after r320604.
As a result of this change, the basic_stringbuf constructor that
takes a mode ends up leaving __hm_ set to 0, causing the comparison
"__hm_ - __str_.data() < __noff" in seekoff() to succeed, which caused
the function to incorrectly return -1. The fix is to account for the
possibility of __hm_ being 0 when computing the distance from __hm_
to the start of the string.

Differential Revision: https://reviews.llvm.org/D41319

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@321124 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-19 23:33:16 +00:00
Zhihao Yuan
4159a369fe [libcxx] Fix basic_stringbuf constructor
Summary:
[libcxx] Fix basic_stringbuf constructor

The C++ Standard [stringbuf.cons]p1 defines the effects of the basic_stringbuf
constructor that takes ios_base::openmode as follows:
  Effects: Constructs an object of class basic_stringbuf, initializing the
  base class with basic_streambuf(), and initializing mode with which.
  Postconditions: str() == "".

The default constructor of basic_streambuf shall initialize all its
pointer member objects to null pointers [streambuf.cons]p1.

Currently libc++ calls "str(string_type());" in the aforementioned constructor
setting basic_streambuf's pointers to a non-null value.

This patch removes the call (note that the postcondition str() == ""
remains valid because __str_ is default-initialized) and adds a test checking
that the basic_streambuf's pointers are null after construction.

Thanks Mikhail Maltsev for the patch.

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D40707

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@320604 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 18:12:55 +00:00
Stephan T. Lavavej
1a35e84a5c [libcxx] [test] Untabify stringstream.cons/string.pass.cpp. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@310157 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-05 00:44:27 +00:00
Marshall Clow
db84e0edae Fix shadowing warning
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309851 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 18:21:34 +00:00
Marshall Clow
b3d6031a54 Fix PR33727: std::basic_stringbuf only works with DefaultConstructible allocators. Thanks to Jonathan Wakely for the report and suggested fix
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309838 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 17:31:09 +00:00
Eric Fiselier
e915b5c1f2 Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output library
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 23:38:41 +00:00
Stephan T. Lavavej
e2dbcaf969 [libcxx] [test] D27266: Remove spurious semicolons.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288750 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 01:14:06 +00:00
Stephan T. Lavavej
a9bcd3dae8 [libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", part 1/12.
Change loop indices from int to std::size_t.

Also, include <cstddef> when it wasn't already being included.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23 22:01:19 +00:00
Eric Fiselier
22bff1afcc Move remaining _LIBCPP_VERSION tests into test/libcxx
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273367 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 02:23:22 +00:00
Marshall Clow
0f7221ccb8 Fix up typos in a couple of tests; due to agressive short-circuiting, they never failed on clang or gcc, but MSVC whined. Patch by Andrew Parker.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242618 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 18:24:15 +00:00
Eric Fiselier
a90c6dd460 Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-20 01:40:03 +00:00