https://bugs.llvm.org/show_bug.cgi?id=51973

            Bug ID: 51973
           Summary: Default non-type template parameters with immediately
                    invoked lambdas fail with deduction guides
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

With the following code, clang claims the defaulted non-type template parameter
is not a constant expression, despite it being so (with GCC handling it fine as
well):

#include <concepts>

template<
    typename T,
    auto V = []() {
        if constexpr (std::same_as<T, int>) {
            return 1;
        } else {
            return 2;
        }
    }()
>
struct Test {
    constexpr Test(T) { }
};

template<typename T>
Test(T) -> Test<T>;

void test() {
    Test<int, 1>(1);
}

Godbolt link: https://godbolt.org/z/jT3zPx9fx

As you can see, even if you specify the template parameters when constructing,
it still complains, and if you duplicate the immediately invoked lambda in the
deduction guide and remove the explicated template arguments for the
constructor, clang actually says that it can't compile that expression yet.
However, if you specify the template arguments, it consumes everything fine.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to