https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119688
Bug ID: 119688 Summary: literal operator template instantiated only once (c++20) Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yannick.daveluy at gmail dot com Target Milestone: --- With user defined literal operator template there is a problem of template instantiation. It seems the the first instantiation stay in cache. Here is a reproducible program: ```c++ #include <array> template <std::size_t N> struct builder { std::array<bool, 256> value{}; explicit(false) constexpr builder(char const (&s)[N]) { for(auto i = 0 ; i < N;++i) value[static_cast<unsigned char>(s[i])] = true; } }; template<builder A> constexpr auto operator""_ar() { return A.value; } constexpr auto first = "ab"_ar; static_assert(first['a']); static_assert(first['b']); static_assert(!first['c']); static_assert(!first['d']); constexpr auto second = "cd"_ar; static_assert(!second['a']); // error: static assertion failed static_assert(!second['b']); // error: static assertion failed static_assert(second['c']); // error: static assertion failed static_assert(second['d']); // error: static assertion failed // -> second seems to be equal to "ab"_cr instead of ""cd"_cr ``` FYI this code works as expected using Clang.