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

            Bug ID: 84491
           Summary: Multiple inheritance and covariant return types causes
                    internal compiler error
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christopher.hood at gtri dot gatech.edu
  Target Milestone: ---

With respect to GCC 7.3.0, but I have tested on other GCCs down to 4.7 with the
same result.

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --enable-multilib --disable-werror
--enable-checking=release --enable-default-pie --enable-default-ssp
Thread model: posix
gcc version 7.3.0 (GCC) 

This example using multiple inheritance and two branches of covariant virtual
functions causes the internal compiler error: 

test-thunk-error.cc: In instantiation of ‘struct Parents<Constituent<Foo, Bar>
>’:
test-thunk-error.cc:8:8:   required from ‘struct InterfaceBase<FooWithBar,
Constituent<Foo, Bar> >’
test-thunk-error.cc:37:24:   required from here
test-thunk-error.cc:4:8: internal compiler error: in make_thunk, at
cp/method.c:115
 struct Parents : P::Interface...
        ^~~~~~~

Judicious commenting of certain seemingly non-offensive lines will cause
compilation to succeed (any of lines commented a,b,c,d). The code which breaks
GCC does compile without error on Clang.


Example listing:

template <class ... P>
struct Parents : P::Interface...
{};

template <class T, class ... P>
struct InterfaceBase : Parents<P...>
{
    virtual T* Model ()=0; // a
};

struct Foo
{
    struct Interface : InterfaceBase<Foo>
    {};
    virtual Interface* Iface ()=0; // b
};

struct Bar
{
    struct Interface : InterfaceBase<Bar>
    {};
    virtual Interface* Iface ()=0; // c
};

template <class T, class U>
struct Constituent : T, U
{
    struct Interface : InterfaceBase<Constituent, T, U>
    {};    
    virtual Interface* Iface ()=0; // d
};

struct FooWithBar : Constituent<Foo, Bar>
{
    struct Interface : InterfaceBase<FooWithBar, Constituent>
    {};
};

int main ()
{
    return 0;
}

Reply via email to