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

            Bug ID: 99107
           Summary: Ignored inconsistent parameter/arguments types in
                    variadic templates
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: oleksandr.koval.dev at gmail dot com
  Target Milestone: ---

template<typename... Ts>
struct Types {};

struct X {};
struct Y {};
struct Z {};
struct W {
    operator Y(){return Y{};}
    operator Z(){return Z{};}
};

template<typename... Ts>
void ctor(Types<Ts...>, Ts...){}

This is an error:

ctor(Types<X, Y, Z>{}, X{}, Y{}, W{});

because of mismatch during deduction: first pack is deduced to <X,Y,Z> but
second is <X,Y,W>, conversions are not allowed here.

Here we have the same mismatched types but, currently, it's OK:

ctor(Types<X, Y, Z>{}, {}, {}, W{});

I've noticed this problem while playing with CTAD for aggregates:

template<typename... Ts>
struct F : Types<Ts...>, Ts...
{};

// error, as expected
F f3 = {Types<X, Y, Z>{}, X{}, W{}};

// should also be an error
F f4 = {Types<X, Y, Z>{}, {}, W{}};

Reply via email to