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

            Bug ID: 92601
           Summary: error: type variant differs by TYPE_NEEDS_CONSTRUCTING
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: ice-checking
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: jason at gcc dot gnu.org
  Target Milestone: ---

Happens for the following test-case:

$ cat verify.ii
typedef int size_t;
template <typename, int __v> struct integral_constant {
  static constexpr int value = __v;
};
template <typename> struct A;
template <typename _Tp> using __remove_cv_t = typename A<_Tp>::type;
template <typename _Tp, typename _Up>
struct B : integral_constant<bool, __is_same_as(_Tp, _Up)> {};
template <typename...> class tuple;
template <typename> struct A {
  using type = tuple<const char *, const char *>;
};
template <typename> struct C { typedef __remove_cv_t<int> __type; };
template <typename _Tp> class D {
public:
  typedef typename C<_Tp>::__type type;
};
template <bool> struct enable_if;
template <int> struct F {};
template <typename, typename> class G {
public:
  int operator*();
  void operator++();
};
template <typename _Iterator, typename _Container>
bool operator!=(G<_Iterator, _Container>, G<_Iterator, _Container>);
template <typename> class H;
template <typename = H<tuple<const char *, const char *>>> class vector {
public:
  typedef G<int, vector> iterator;
  iterator begin();
  iterator end();
};
template <typename> struct pack_c { typedef pack_c type; };
template <typename, typename> struct make_index_pack_join;
template <size_t... Left, size_t... Right>
struct make_index_pack_join<pack_c<size_t, Left...>, pack_c<size_t, Right...>>
    : pack_c<size_t> {};
template <int N>
struct I
    : make_index_pack_join<typename I<N / 2>::type, typename I<N / 2>::type>
{};
template <> struct I<1> : pack_c<size_t> {};
template <typename TTuple, typename>
struct are_tuples_compatible_not_same
    : F<B<typename D<TTuple>::type, int>::value> {};
template <typename...> struct tuple_impl;
template <size_t... Is, typename... Ts>
struct tuple_impl<pack_c<size_t, Is...>, Ts...> {
  template <typename UTuple, typename enable_if<are_tuples_compatible_not_same<
                                 tuple<>, UTuple>::value>::type>
  tuple_impl(UTuple &&);
};
template <typename... Ts> class tuple {
  tuple_impl<typename I<sizeof...(Ts)>::type> _impl;
  tuple(tuple &) = default;
};
vector message_handler_registrations;
void fn1() {
  for (auto t : message_handler_registrations)
    ;
}

$ g++ -std=c++17 -fchecking verify.ii -c -g
verify.ii: In instantiation of ‘struct C<tuple<> >’:
verify.ii:16:35:   required from ‘class D<tuple<> >’
verify.ii:44:8:   required from ‘struct are_tuples_compatible_not_same<tuple<>,
tuple_impl<pack_c<int> >&>’
verify.ii:50:60:   required by substitution of ‘template<class UTuple, typename
enable_if<are_tuples_compatible_not_same<tuple<>, UTuple>::value>::type
<anonymous> > tuple_impl<pack_c<int> >::tuple_impl(UTuple&&) [with UTuple =
tuple_impl<pack_c<int> >&; typename
enable_if<are_tuples_compatible_not_same<tuple<>, UTuple>::value>::type
<anonymous> = <missing>]’
verify.ii:53:33:   required from ‘class tuple<const char*, const char*>’
verify.ii:59:17:   required from here
verify.ii:13:28: error: type variant differs by TYPE_NEEDS_CONSTRUCTING
   13 | template <typename> struct C { typedef __remove_cv_t<int> __type; };
      |                            ^
 <record_type 0x7fe19d1e01f8 tuple visited needs-constructing type_1 type_5
type_6 VOID
    align:8 warn_if_not_align:0 symtab:-1660242848 alias-set -1 canonical-type
0x7fe19d1e01f8
    fields <field_decl 0x7fe19d1f3558 _impl
        type <record_type 0x7fe19d202738 tuple_impl asm_written
needs-constructing type_1 type_5 type_6 QI
            size <integer_cst 0x7fe19d08ff18 constant 8>
            unit-size <integer_cst 0x7fe19d08ff30 constant 1>
            align:8 warn_if_not_align:0 symtab:-1658842336 alias-set -1
canonical-type 0x7fe19d202738 fields <function_decl 0x7fe19d209100 __ct >
context <translation_unit_decl 0x7fe19d09c168 verify.ii>
            full-name "struct tuple_impl<pack_c<int> >"
            needs-constructor X(constX&) this=(X&) n_parents=0 use_template=1
interface-unknown
            pointer_to_this <pointer_type 0x7fe19d2065e8> reference_to_this
<reference_type 0x7fe19d207498> chain <type_decl 0x7fe19d1f3ab0 tuple_impl>>
        private nonlocal decl_3 VOID verify.ii:54:47
        align:1 warn_if_not_align:0 offset_align 1 context <record_type
0x7fe19d1e01f8 tuple>
        chain <function_decl 0x7fe19d200d00 __ct  type <method_type
0x7fe19d2070a8>
            public private external autoinline QI verify.ii:55:3 align:16
warn_if_not_align:0 context <record_type 0x7fe19d1e01f8 tuple>
            full-name "tuple< <template-parameter-1-1> >::tuple(tuple<
<template-parameter-1-1> >&) [with Ts = {const char*, const char*}]"
            template-info 0x7fe19d204bc0 chain <type_decl 0x7fe19d1f34c0
tuple>>> context <translation_unit_decl 0x7fe19d09c168 verify.ii>
    full-name "class tuple<const char*, const char*>"
    needs-constructor X(X&) this=(X&) n_parents=0 use_template=1
interface-unknown
    pointer_to_this <pointer_type 0x7fe19d207000> reference_to_this
<reference_type 0x7fe19d206e70> chain <type_decl 0x7fe19d1de428 tuple>>
 <record_type 0x7fe19d1e09d8 __remove_cv_t type_5 VOID
    align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fe19d1e01f8 context <translation_unit_decl 0x7fe19d09c168 verify.ii>
    full-name "__remove_cv_t<int>"
    X(X&) this=(X&) n_parents=0 use_template=1 interface-unknown
    chain <type_decl 0x7fe19d1de428 tuple>>
verify.ii:13: confused by earlier errors, bailing out

$ g++ -std=c++17 -fchecking verify.ii -c
is fine, started with r258964, before that the code was rejected.

Reply via email to