From 8c78eb363b289484396edc3c2550bf8c655d4687 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Tue, 10 Nov 2026 07:19:21 +0900 Subject: [PATCH] [Helper] Avoid GCC LTO internal compiler error in makeFixedSizeTypeName Indexing the array with std::string_view::size_type expressions in the constant initializer of the VecTypes/RigidTypes type names makes GCC crash when a file calling Name() at runtime is compiled with LTO (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114501). Keep the sizes as std::size_t instead. --- Sofa/framework/Helper/src/sofa/helper/StringUtils.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sofa/framework/Helper/src/sofa/helper/StringUtils.h b/Sofa/framework/Helper/src/sofa/helper/StringUtils.h index 8de84cde877..2982e5ba0ed 100644 --- a/Sofa/framework/Helper/src/sofa/helper/StringUtils.h +++ b/Sofa/framework/Helper/src/sofa/helper/StringUtils.h @@ -124,17 +124,20 @@ constexpr static auto makeFixedSizeTypeName() constexpr std::size_t d = sofa::helper::numDigits(N); constexpr auto suffix = type::TypeTrait::suffix; - std::array s{}; + constexpr std::size_t prefixSize = prefix.size(); + constexpr std::size_t suffixSize = suffix.size(); + + std::array s{}; std::copy(prefix.begin(), prefix.end(), s.begin()); int n = N; for (int i = d - 1; i >= 0; --i) { - s[prefix.size() + i] = static_cast('0' + n % 10); + s[prefixSize + i] = static_cast('0' + n % 10); n /= 10; } //suffix - std::copy(suffix.begin(), suffix.end(), s.begin() + prefix.size() + d); - s[prefix.size() + d + suffix.size()] = '\0'; + std::copy(suffix.begin(), suffix.end(), s.begin() + prefixSize + d); + s[prefixSize + d + suffixSize] = '\0'; return s; }