From 6f0c00b2687f252b4a1e9f5712013de97688516a Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 18 Dec 2025 10:35:43 +0100 Subject: [PATCH] Work around a Clang 3.7 bug affecting constexpr insert() The iterator-based insert(const_iterator, size_type, value_type) function relies on traits_type::move() to shift the existing null terminator to its new position. Clang 3.7's constexpr evaluator does not handle this correctly, causing the following test to fail: static_string<3>{"ab"}.insert(2, 1, 'c') == "abc" Add an explicit term() call, guarded by a preprocessor conditional for Clang 3.7, to ensure proper null termination. --- include/boost/static_string/static_string.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/static_string/static_string.hpp b/include/boost/static_string/static_string.hpp index 75556d3..6b4d3d0 100644 --- a/include/boost/static_string/static_string.hpp +++ b/include/boost/static_string/static_string.hpp @@ -6707,6 +6707,9 @@ insert( traits_type::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1); traits_type::assign(&curr_data[index], count, ch); this->size_impl(curr_size + count); +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ == 7 + term(); +#endif return &curr_data[index]; }