-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"libstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard library
Description
using this constexpr boost static_string (requires static_string develop) does not compile with clang against libstdc++ (g++ compiles against libstdc++ also clang++ compiles against libc++).
#include <boost/static_string.hpp>
using str = boost::static_strings::static_string<38>;
constexpr str a{ "mystr" };c.cpp:5:15: error: constexpr variable 'a' must be initialized by a constant expression
constexpr str a{ "mystr" };
^~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/char_traits.h:213:13: note: subexpression not valid in a constant expression
if (__s1 == __s2)
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/char_traits.h:417:11: note: in call to 'move(&a.static_string_base::data_[0], &"mystr"[0], 5)'
return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
^
/home/tim/NIBuild/3rdparty/boost-v1.78.0-R8/boost/static_string/static_string.hpp:6000:3: note: in call to 'move(&a.static_string_base::data_[0], &"mystr"[0], 5)'
traits_type::move(data(), s, size());
^
/home/tim/NIBuild/3rdparty/boost-v1.78.0-R8/boost/static_string/static_string.hpp:1413:12: note: in call to '&a->assign(&"mystr"[0], 5)'
return assign(s, traits_type::length(s));
^
/home/tim/NIBuild/3rdparty/boost-v1.78.0-R8/boost/static_string/static_string.hpp:961:5: note: in call to '&a->assign(&"mystr"[0])'
assign(s);
^
c.cpp:5:15: note: in call to 'basic_static_string(&"mystr"[0])'
constexpr str a{ "mystr" };
^
1 error generated.
the offending code in libstdc++ is this one:
if (__s1 == __s2) // unlikely, but saves a lot of work
return __s1;
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/char_traits.h#L216-L217
Metadata
Metadata
Assignees
Labels
c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"libstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard library