[llvm-bugs] [Bug 38962] New: Clang doesn't allow constexpr values of user-defined literal types to be used in lambdas without being captured

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 15 17:55:19 PDT 2018


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

            Bug ID: 38962
           Summary: Clang doesn't allow constexpr values of user-defined
                    literal types to be used in lambdas without being
                    captured
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: heavenandhell171 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Tests taken from: https://github.com/SephDB/constexpr-format#compiler-support

void testNativeLiteralType() {
    //Compiles fine
    constexpr int n = 0;
    auto D = []{return n;};
    constexpr auto x = D();
}

//Obviously literal type
struct A {
    int a = 0;
};

void testNonNativeLiteralType() {
    //Doesn't compile on clang
    constexpr auto n = A{};
    auto D = []{return n;};
    constexpr auto x = D();
}

Clang: https://godbolt.org/z/ECxj4p
GCC: https://godbolt.org/z/aTiqrx

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180916/1fe7129f/attachment.html>


More information about the llvm-bugs mailing list