https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768
--- Comment #3 from biggs at biggs dot xyz --- (In reply to Andrew Pinski from comment #1) > >The unused constexpr names aren't optimized out but the const*const ones are. > > > They are different. > In the constexpr case, you have an array of array of char. In the const case > you have an array of pointers. In C++ you could write: https://godbolt.org/z/EKvfvjedG ```cpp #include <array> #include <iostream> #include <string_view> enum struct Color { RED, GREEN, BLUE }; int main() { using namespace std::string_view_literals; static constexpr std::array names = {"RED"sv, "GREEN"sv, "BLUE"sv}; std::puts(names.at(static_cast<std::size_t>(Color::RED)).data()); } ``` The unused names are optimized out here and string_view is simply a contiguous array of characters not pointers.