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

            Bug ID: 88848
           Summary: member ambiguous in multiple inheritance lattice
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

clang++/icc compile this fine, but g++ says:

bz.C: In substitution of ‘template<class ... ARGS> template<int VALUE> using
Type_t = decltype (#‘using_decl’ not supported by dump_expr#<expression
error>(Integer<VALUE>{})) [with int VALUE = Integer<4>::value; ARGS = {Foo<4,
float>, Foo<8, double>}]’:
bz.C:21:54:   required from ‘struct Bar<Foo<4, float>, Foo<8, double> >’
bz.C:30:38:   required from here
bz.C:21:35: error: request for member ‘get_type’ is ambiguous in multiple
inheritance lattice
   21 |   using Type_t = decltype(get_type(Integer<VALUE>{}));
      |                           ~~~~~~~~^~~~~~~~~~~~~~~~~~
bz.C:12:15: note: candidates are: ‘static TYPE Foo<VALUE,
TYPE>::get_type(Foo<VALUE, TYPE>::Integer_t) [with int VALUE = 8; TYPE =
double; Foo<VALUE, TYPE>::Integer_t = Integer<8>]’
   12 |   static TYPE get_type(Integer_t);
      |               ^~~~~~~~
bz.C:12:15: note:                 ‘static TYPE Foo<VALUE,
TYPE>::get_type(Foo<VALUE, TYPE>::Integer_t) [with int VALUE = 4; TYPE = float;
Foo<VALUE, TYPE>::Integer_t = Integer<4>]’



template<typename>
struct True { static constexpr bool value{ true }; };

template<int VALUE>
struct Integer { static constexpr int value{ VALUE }; };

template<int VALUE, typename TYPE>
struct Foo
{
  using Integer_t = Integer<VALUE>;

  static TYPE get_type(Integer_t);
};

template<typename... ARGS>
struct Bar : ARGS...
{
  using ARGS::get_type...;

  template<int VALUE>
  using Type_t = decltype(get_type(Integer<VALUE>{}));

  Bar() { static_assert((True< Type_t<ARGS::Integer_t::value> >::value &&
...)); }

  static_assert((True< Type_t<ARGS::Integer_t::value> >::value && ...));
};

int main()
{
  Bar<Foo<4, float>, Foo<8, double>> obj;
  return int{ sizeof(obj) };
}

Reply via email to