Bug 102644 - deduction failure when having default non-type template parameters that are lambdas
Summary: deduction failure when having default non-type template parameters that are l...
Status: RESOLVED DUPLICATE of bug 93595
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, rejects-valid
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2021-10-07 21:01 UTC by Barry Revzin
Modified: 2022-03-11 00:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-10-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Revzin 2021-10-07 21:01:24 UTC
gcc trunk with -std=c++20 rejects this example as having no matching function call:

template <auto V1 = []{ return 0; }>
struct s {
    template <auto V2 = []{ return 1; }>
    int foo() { return 0; }
};

int main() {
    return s{}.foo();
}

gcc accepts if:

* foo()'s default argument is 1 instead of a lambda
* s is not a class template (but changing V1's default to be 0 while keeping V2 as a lambda is still an error)
Comment 1 Andrew Pinski 2021-10-08 21:03:12 UTC
Confirmed.

Here is another example:
template <auto V1 = 0>
struct s {
    template <auto V2 = []{ return 1; }>
    int foo() { return 0; }
};

int main() {
    s a{};
    return a.foo();
}

---- CUT ----
Note the original example causes clang to ICE :) while this one is accepted.
Comment 2 Andrew Pinski 2021-12-20 06:55:19 UTC
Dup of bug 93595.

*** This bug has been marked as a duplicate of bug 93595 ***