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

            Bug ID: 79264
           Summary: ICE verify_type failed
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guille at berkeley dot edu
  Target Milestone: ---

The following code ICEs on:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin13.4.0/7.0.1/lto-wrapper
Target: x86_64-apple-darwin13.4.0
Configured with: ../configure --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 7.0.1 20170122 (experimental) (GCC)

Compiled with:
c++ test.c  -std=c++1z -fconcepts -g3

*NOTE*: when removing '-g3' it no longer ICEs. 


Code has been simplified as much as possible. Note: removing the 'std::decay_t'
gives a "silent" ICE notification ("t.c:48:1: internal compiler error:
Segmentation fault: 11").
------------


#include <tuple>


template <class C> struct Wrapper
{
    C c_;

    template <class F> struct signature_imp
    {};

    template <class T, class R, class... A> struct signature_imp<R(T::*)(A...)
const>
    {
        template <int n> using arg_t = std::tuple_element_t<n,
std::tuple<A...>>;
    };

    template <class F> struct signature : public
signature_imp<decltype(&std::decay_t<F>::template operator() <C>)>
    {};

    template <class F> requires std::is_same_v<C&, typename
signature<F>::template arg_t<0>> auto call(const F& f)
    {
        return f(c_);
    }
};


struct A
{
    Wrapper<int> w_;

    template <class U> void g(auto)
    {
    }

public:
    void f()
    {
        w_.call([&] (auto&)
        {
            g<int> ([] (auto) {});
        });
    }
};


int main()
{
    return 0;
}


Output:
-------

$ c++ t.c  -std=c++1z -fconcepts -g3
t.c:48:1: error: type variant has different TYPE_FIELDS
 }
 ^
 <record_type 0x10328ef18 __lambda0 asm_written type_5 type_6 QI
    size <integer_cst 0x144f01fa8 type <integer_type 0x144f200a8 bitsizetype>
constant 8>
    unit size <integer_cst 0x144f01fc0 type <integer_type 0x144f20000 sizetype>
constant 1>
    align 8 symtab 51474176 alias set -1 canonical type 0x10328ef18
    fields <field_decl 0x10329cda8 __this
        type <pointer_type 0x10328e9d8 type <record_type 0x103289e70 A>
            readonly unsigned type_6 DI
            size <integer_cst 0x144f01eb8 constant 64>
            unit size <integer_cst 0x144f01ed0 constant 8>
            align 64 symtab 0 alias set -1 canonical type 0x10328e9d8>
        used decl_7 VOID file t.c line 39 col 4
        align 1 offset_align 1 context <record_type 0x10328ef18 __lambda0>
        chain <type_decl 0x10328f4c0 __lambda0 type <record_type 0x10328e498
__lambda0>
            nonlocal decl_4 VOID file t.c line 37 col 13
            align 1 context <record_type 0x10328ef18 __lambda0> result
<record_type 0x10328ef18 __lambda0>
           >> context <function_decl 0x103278800 f>
    full-name "struct A::f()::<lambda(auto:2&)>"
    X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
    pointer_to_this <pointer_type 0x103292d20> chain <type_decl 0x10328f428
__lambda0>>
t.c:48:1: error: first mismatch is field
 <type_decl 0x10328f4c0 __lambda0
    type <record_type 0x10328e498 __lambda0 type_5 QI
        size <integer_cst 0x144f01fa8 constant 8>
        unit size <integer_cst 0x144f01fc0 constant 1>
        align 8 symtab 0 alias set -1 canonical type 0x10328ef18 fields
<type_decl 0x10328f4c0 __lambda0> context <function_decl 0x103278800 f>
        full-name "struct A::f()::<lambda(auto:2&)>"
        X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
        chain <type_decl 0x10328f428 __lambda0>>
    nonlocal decl_4 VOID file t.c line 37 col 13
    align 1 context <record_type 0x10328ef18 __lambda0>
    result <record_type 0x10328ef18 __lambda0 asm_written type_5 type_6 QI size
<integer_cst 0x144f01fa8 8> unit size <integer_cst 0x144f01fc0 1>
        align 8 symtab 51474176 alias set -1 canonical type 0x10328ef18
        fields <field_decl 0x10329cda8 __this type <pointer_type 0x10328e9d8>
            used decl_7 VOID file t.c line 39 col 4
            align 1 offset_align 1 context <record_type 0x10328ef18 __lambda0>
chain <type_decl 0x10328f4c0 __lambda0>> context <function_decl 0x103278800 f>
        full-name "struct A::f()::<lambda(auto:2&)>"
        X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
        pointer_to_this <pointer_type 0x103292d20> chain <type_decl 0x10328f428
__lambda0>>
   >
t.c:48:1: error: and field
 <field_decl 0x10329cda8 __this
    type <pointer_type 0x10328e9d8
        type <record_type 0x103289e70 A asm_written type_5 type_6 SI
            size <integer_cst 0x144f23108 constant 32>
            unit size <integer_cst 0x144f23120 constant 4>
            align 32 symtab 51473376 alias set -1 canonical type 0x103289e70
fields <field_decl 0x10328f1c8 w_> context <translation_unit_decl 0x144f0f168
D.1>
            full-name "struct A"
            X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
            pointer_to_this <pointer_type 0x10328e888> chain <type_decl
0x10328a130 A>>
        readonly unsigned type_6 DI
        size <integer_cst 0x144f01eb8 constant 64>
        unit size <integer_cst 0x144f01ed0 constant 8>
        align 64 symtab 0 alias set -1 canonical type 0x10328e9d8>
    used decl_7 VOID file t.c line 39 col 4
    align 1 offset_align 1 context <record_type 0x10328ef18 __lambda0> chain
<type_decl 0x10328f4c0 __lambda0>>
 <record_type 0x103292150 __lambda0 readonly type_5 type_6 QI
    size <integer_cst 0x144f01fa8 type <integer_type 0x144f200a8 bitsizetype>
constant 8>
    unit size <integer_cst 0x144f01fc0 type <integer_type 0x144f20000 sizetype>
constant 1>
    align 8 symtab 56696416 alias set -1 canonical type 0x103292150
    fields <type_decl 0x10328f4c0 __lambda0
        type <record_type 0x10328e498 __lambda0 type_5 QI size <integer_cst
0x144f01fa8 8> unit size <integer_cst 0x144f01fc0 1>
            align 8 symtab 0 alias set -1 canonical type 0x10328ef18 fields
<type_decl 0x10328f4c0 __lambda0> context <function_decl 0x103278800 f>
            full-name "struct A::f()::<lambda(auto:2&)>"
            X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
            chain <type_decl 0x10328f428 __lambda0>>
        nonlocal decl_4 VOID file t.c line 37 col 13
        align 1 context <record_type 0x10328ef18 __lambda0>
        result <record_type 0x10328ef18 __lambda0 asm_written type_5 type_6 QI
size <integer_cst 0x144f01fa8 8> unit size <integer_cst 0x144f01fc0 1>
            align 8 symtab 51474176 alias set -1 canonical type 0x10328ef18
fields <field_decl 0x10329cda8 __this> context <function_decl 0x103278800 f>
            full-name "struct A::f()::<lambda(auto:2&)>"
            X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
            pointer_to_this <pointer_type 0x103292d20> chain <type_decl
0x10328f428 __lambda0>>
       > context <function_decl 0x103278800 f>
    full-name "const struct A::f()::<lambda(auto:2&)>"
    X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
    pointer_to_this <pointer_type 0x1032922a0> reference_to_this
<reference_type 0x1032952a0>>
t.c:48:1: internal compiler error: verify_type failed

t.c:48:1: internal compiler error: Abort trap: 6
c++: internal compiler error: Abort trap: 6 (program cc1plus)

Reply via email to