Skip to content

[15->17trunk regression] Parameter packs in requires-clauses in deduction guides are considered non-constant #60777

@Alcaro

Description

@Alcaro
template<typename... Ts>
constexpr bool True() { return true; }

template<typename T>
class A {
public:
    template<typename... Ts>
    A(T val, Ts... tail)
    requires (True<Ts...>())
    {}
};

int main() {
    A b(42);
}

Works on GCC, MSVC, and Clang 15.0.0. But on 17.0.0-26662ac010ef50e65e2774eab84f325aa09360fe, it fails with

<source>:9:15: error: substitution into constraint expression resulted in a non-constant expression
    requires (True<Ts...>())
              ^~~~~~~~~~~~~
<source>:14:7: note: while checking constraint satisfaction for template '<deduction guide for A><int>' required here
    A b(42);
      ^
<source>:14:7: note: in instantiation of function template specialization '<deduction guide for A><int>' requested here
<source>:9:15: note: non-literal type '<dependent type>' cannot be used in a constant expression
    requires (True<Ts...>())
              ^
<source>:14:7: error: no viable constructor or deduction guide for deduction of template arguments of 'A'
    A b(42);
      ^
<source>:8:5: note: candidate template ignored: failed template argument deduction
    A(T val, Ts... tail)
    ^
<source>:5:7: note: candidate template ignored: could not match 'A<T>' against 'int'
class A {
      ^

https://godbolt.org/z/sh7TrPGE1

I also found an ICE-on-invalid that I suspect may have the same root cause and/or same solution: https://godbolt.org/z/7qGTddsYh If it doesn't, feel free to ignore it; if this bug is fixed but the ICE remains, I'll file a new bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions