Skip to content

Commit

Permalink
enforce "non-array trivial standard-layout" for basic_string and basi…
Browse files Browse the repository at this point in the history
…c_string_view (#1262)
  • Loading branch information
fsb4000 authored Sep 5, 2020
1 parent 4f72f78 commit be0441c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 8 additions & 0 deletions stl/inc/xstring
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,10 @@ public:
"Bad char_traits for basic_string_view; "
"N4659 24.4.2 [string.view.template]/1 \"the type traits::char_type shall name the same type as charT.\"");

static_assert(!is_array_v<_Elem> && is_trivial_v<_Elem> && is_standard_layout_v<_Elem>,
"The character type of basic_string_view must be a non-array trivial standard-layout type. See N4861 "
"[strings.general]/1.");

using traits_type = _Traits;
using value_type = _Elem;
using pointer = _Elem*;
Expand Down Expand Up @@ -2290,6 +2294,10 @@ private:
"N4659 24.3.2.1 [string.require]/3 requires that the supplied "
"char_traits character type match the string's character type.");

static_assert(!is_array_v<_Elem> && is_trivial_v<_Elem> && is_standard_layout_v<_Elem>,
"The character type of basic_string must be a non-array trivial standard-layout type. See N4861 "
"[strings.general]/1.");

public:
using traits_type = _Traits;
using allocator_type = _Alloc;
Expand Down
3 changes: 0 additions & 3 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,6 @@ std/containers/sequences/array/array.data/data_const.pass.cpp FAIL
std/containers/sequences/array/array.data/data.pass.cpp FAIL
std/containers/sequences/array/iterators.pass.cpp FAIL

# STL bug: string_view doesn't enforce "non-array trivial standard-layout", related to LWG-3034.
std/strings/string.view/char.bad.fail.cpp:0 FAIL

# Predicate count assertions - IDL2 is slightly bending the Standard's rules here.
std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp FAIL
std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp FAIL
Expand Down
3 changes: 0 additions & 3 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,6 @@ containers\sequences\array\array.data\data_const.pass.cpp
containers\sequences\array\array.data\data.pass.cpp
containers\sequences\array\iterators.pass.cpp

# STL bug: string_view doesn't enforce "non-array trivial standard-layout", related to LWG-3034.
strings\string.view\char.bad.fail.cpp

# Predicate count assertions - IDL2 is slightly bending the Standard's rules here.
algorithms\alg.sorting\alg.heap.operations\make.heap\make_heap_comp.pass.cpp
algorithms\alg.sorting\alg.merge\inplace_merge_comp.pass.cpp
Expand Down

0 comments on commit be0441c

Please sign in to comment.