https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87772

            Bug ID: 87772
           Summary: Crash with variadic template, constexpr constructor
                    for templated non-literal type, using declaration
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stypox at pm dot me
  Target Milestone: ---

Created attachment 44911
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44911&action=edit
Preprocessed code from the main.cpp file in the description

* Version:

$g++ --version
g++ (Debian 8.2.0-7) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



* To compile I used (but -save-temps doesn't change anything):

g++ -Wall -g -std=c++17 -o main.o -c main.cpp -save-temps



* Running that command generates the attached preprocessed code and gives this
error:

$g++ -Wall -g -std=c++17 -o main.o -c main.cpp -save-temps
main.cpp: In instantiation of ‘struct
Parser<std::array<std::array<SentenceBase<void>, 1>, 1> >’:
main.cpp:24:53:   required from here
main.cpp:16:8: internal compiler error: in is_base_type, at dwarf2out.c:12911
 struct Parser {
        ^~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.



* This is the main.cpp file, in case it is needed. It contains much nonsense
because I removed all the things that didn't change the result of the
compilation. When I write "/* or whatever */" I mean that the value/type there
is just a placeholder and could be anything.

#include <array>
#include <string>

template<typename T>
struct SentenceBase {
        std::string m_code;
        constexpr SentenceBase() {}
};

template <bool ... Conditions> struct true_all {};
template <>                                        struct true_all<>           
                         : std::true_type {};
template <bool ... Conditions> struct true_all<false, Conditions...> :
std::false_type {};
template <bool ... Conditions> struct true_all<true, Conditions...>  :
true_all<Conditions...>::type {};

template<typename ... Container>
struct Parser {
        using rightTypesGuard =
std::enable_if_t<true_all<std::is_literal_type_v<typename
Container::value_type>...>::value>;
};

template<typename ... Types>
auto make_parser(Types... sentences) -> Parser<std::array<Types, 1 /* or
whatever */>...> {}

int main() {
        make_parser(std::array<SentenceBase<void /* or whatever */>, 1 /* or
whatever */>{{}});
}

Reply via email to