File tree 6 files changed +17
-32
lines changed
libcxx/strings/basic.string/string.capacity
std/strings/basic.string/string.capacity
6 files changed +17
-32
lines changed Original file line number Diff line number Diff line change @@ -275,11 +275,10 @@ ABI Affecting Changes
275
275
results in an ABI break, however in practice we expect uses of ``std::projected `` in ABI-sensitive places to be
276
276
extremely rare. Any error resulting from this change should result in a link-time error.
277
277
278
- - Under the unstable ABI, the internal alignment requirements for heap allocations
279
- inside ``std::string `` has decreased from 16 to 8. This saves memory since string requests fewer additional
280
- bytes than it did previously. However, this also changes the return value of ``std::string::max_size ``
281
- and can cause code compiled against older libc++ versions but linked at runtime to a new version
282
- to throw a different exception when attempting allocations that are too large
278
+ - The internal alignment requirements for heap allocations inside ``std::string `` has decreased from 16 to 8. This
279
+ saves memory since string requests fewer additional bytes than it did previously. However, this also changes the
280
+ return value of ``std::string::max_size `` and can cause code compiled against older libc++ versions but linked at
281
+ runtime to a new version to throw a different exception when attempting allocations that are too large
283
282
(``std::bad_alloc `` vs ``std::length_error ``).
284
283
285
284
- The layout of some range adaptors that use the ``movable-box `` exposition-only type as an implementation
Original file line number Diff line number Diff line change 174
174
// The implementation moved to the header, but we still export the symbols from
175
175
// the dylib for backwards compatibility.
176
176
# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
177
- // Save memory by providing the allocator more freedom to allocate the most
178
- // efficient size class by dropping the alignment requirements for std::string's
179
- // pointer from 16 to 8. This changes the output of std::string::max_size,
180
- // which makes it ABI breaking
181
- # define _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
182
177
# elif _LIBCPP_ABI_VERSION == 1
183
178
# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
184
179
// Enable compiling copies of now inline methods into the dylib to support
Original file line number Diff line number Diff line change @@ -1931,12 +1931,7 @@ private:
1931
1931
return (__s + (__a - 1 )) & ~(__a - 1 );
1932
1932
}
1933
1933
enum {
1934
- __alignment =
1935
- #ifdef _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
1936
- 8
1937
- #else
1938
- 16
1939
- #endif
1934
+ __alignment = 8
1940
1935
};
1941
1936
static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend (size_type __s) _NOEXCEPT {
1942
1937
if (__s < __min_cap) {
Original file line number Diff line number Diff line change 6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ // XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx{{10.13|10.15|11.0}}
10
+
9
11
// <string>
10
12
11
13
// This test demonstrates the smaller allocation sizes when the alignment
17
19
18
20
#include " test_macros.h"
19
21
20
- // alignment of the string heap buffer is hardcoded to either 16 or 8
21
-
22
- const std::size_t alignment =
23
- #ifdef _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
24
- 8 ;
25
- #else
26
- 16 ;
27
- #endif
22
+ // alignment of the string heap buffer is hardcoded to 8
23
+ const std::size_t alignment = 8 ;
28
24
29
25
int main (int , char **) {
30
26
std::string input_string;
Original file line number Diff line number Diff line change 17
17
18
18
#include " test_macros.h"
19
19
20
- // alignment of the string heap buffer is hardcoded to 16
21
-
22
- static const std::size_t alignment =
23
- #ifdef _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
24
- 8 ;
25
- #else
26
- 16 ;
27
- #endif
20
+ // alignment of the string heap buffer is hardcoded to 8
21
+ static const std::size_t alignment = 8 ;
28
22
29
23
template <class = int >
30
24
TEST_CONSTEXPR_CXX20 void full_size () {
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
// UNSUPPORTED: no-exceptions
10
+
11
+ // After changing the alignment of the allocated pointer from 16 to 8, the exception thrown is no longer `bad_alloc`
12
+ // but instead length_error on systems using new headers but older dylibs.
13
+ //
14
+ // XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx{{10.13|10.15|11.0}}
15
+
10
16
// <string>
11
17
12
18
// size_type max_size() const; // constexpr since C++20
You can’t perform that action at this time.
0 commit comments