https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96123
Bug ID: 96123
Summary: [10, trunk] segment fault with NTTP fixed_string
Product: gcc
Version: 10.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lutztonineubert at gmail dot com
Target Milestone: ---
The following code produces a segment fault while compiling with std=c++20 on
GCC 10.1 and trunk.
The problem seems to be the deduction of N in fixed_string.
#include <array>
template<size_t N>
struct fixed_string {
public:
std::array<char, N> content{};
constexpr fixed_string(const char (&str)[N]) {
std::copy(str, str + N - 1, std::begin(content));
}
constexpr auto str() const {
return *this;
}
};
template<auto String>
struct string {};
template<template<fixed_string> typename Token = string>
struct to_string {
template<fixed_string S>
using type = Token<S.str()>;
};
int main() {
using x = typename to_string<>::type<"abc">;
}