Skip to content

Commit 547d8e0

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

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/sv_conversion_test.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ 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+
#if defined(BOOST_CLANG) && (BOOST_CLANG_VERSION >= 150000)
47+
// leads to undefined symbols in Clang < 15: https://github.com/llvm/llvm-project/issues/55560
48+
std::basic_string<Char> s2( (f<Char>( s1 )) );
49+
#endif
50+
BOOST_TEST( s1 == s2 );
51+
}
52+
3253
int main()
3354
{
3455
{
@@ -62,5 +83,15 @@ int main()
6283

6384
#endif
6485

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

0 commit comments

Comments
 (0)