Skip to content

Commit b3a133e

Browse files
committed
Add reproducer for Clang < 15 bug with string_view & C++11 char types
1 parent 749b634 commit b3a133e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/sv_conversion_test.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,29 @@ boost::core::string_view f( boost::core::string_view const& str )
2929
return str;
3030
}
3131

32+
template<typename Char>
33+
boost::core::basic_string_view<Char> f( boost::core::basic_string_view<Char> const& str )
34+
{
35+
return str;
36+
}
37+
38+
template<typename Char>
39+
void subtest()
40+
{
41+
std::basic_string<Char> s1( 3, Char('1') );
42+
s1[1] = Char('2');
43+
s1[2] = Char('3');
44+
45+
std::basic_string<Char> s2 = f<Char>( s1 );
46+
BOOST_TEST( s1 == s2 );
47+
48+
#if ! (defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 150000)
49+
// leads to undefined symbols in Clang < 15: https://github.com/llvm/llvm-project/issues/55560
50+
std::basic_string<Char> s3( (f<Char>( s1 )) );
51+
BOOST_TEST( s1 == s3 );
52+
#endif
53+
}
54+
3255
int main()
3356
{
3457
{
@@ -62,5 +85,15 @@ int main()
6285

6386
#endif
6487

88+
#if !defined(BOOST_NO_CXX11_CHAR16_T)
89+
subtest<char16_t>();
90+
#endif
91+
#if !defined(BOOST_NO_CXX11_CHAR32_T)
92+
subtest<char32_t>();
93+
#endif
94+
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
95+
subtest<char8_t>();
96+
#endif
97+
6598
return boost::report_errors();
6699
}

0 commit comments

Comments
 (0)