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

            Bug ID: 82308
           Summary: [C++17] deduction of template arguments results in
                    internal compiler error
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sdalleig at mmci dot uni-saarland.de
  Target Milestone: ---

Please consider the following code (gcc.godbolt.org link:
https://godbolt.org/g/EX9Fko)

#include <array>

template <size_t R>
class X {
public:
    using T = std::array<int, R>;

    enum class C : uint8_t { A, B };
    X(T bounds, C c = C::B) : t(bounds) {}

private:
    T t;
};

// fix;
// template <size_t R>
// X(std::array<int, R>, ...)->X<Rank>;

int main(void)
{
    std::array<int, 2> a;
    X    d{a}; //cannot be deduced
    X<2> e{a}; // works
}

output: 
In constructor 'X<R>::X(X<R>::T, X<R>::C)':
22 : <source>:22:13: internal compiler error: unexpected expression 'R' of kind
template_parm_index

Reply via email to