Skip to content

Commit 9b1c1ee

Browse files
committed
Check that basic_static_string can be constructed and assigned from a C-style string in a constexpr context
This triggers a libstdc++ issue which was fixed in GCC 12.4 and 13.3: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113200>. If our CI shows we bump into that bug, we'll add a workaround.
1 parent 2f8c7a6 commit 9b1c1ee

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/constexpr_tests.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ bool
6767
testConstantEvaluation()
6868
{
6969
#ifdef BOOST_STATIC_STRING_CPP20
70+
71+
// Check construction in a constexpr context
72+
constexpr basic_static_string s("hello");
73+
static_assert(s.size() == 5);
74+
static_assert(s == "hello");
75+
76+
// Check assignment in a constexpr context
77+
constexpr auto s2 =
78+
[]()
79+
{
80+
basic_static_string s("hello");
81+
s = "world";
82+
return s;
83+
}();
84+
static_assert(s2 == "world");
85+
7086
// c++20 constexpr tests
7187
cstatic_string a;
7288
cstatic_string b(1, 'a');

0 commit comments

Comments
 (0)