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

            Bug ID: 40837
           Summary: Implement CWG 2096
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++'17
          Assignee: unassignedclangb...@nondot.org
          Reporter: ca...@carter.net
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

Compiling this well-formed TU:

    struct nonliteral {
        nonliteral() {}
    };

    union U {
        int head_;
        nonliteral tail_;

        constexpr U() : head_{} {}
    };

    constexpr U u{};

with "clang++ -std=c++17" diagnoses (https://godbolt.org/z/lQKtv8):

    source>:12:17: error: constexpr variable cannot have non-literal type
'const U'
        constexpr U u{};
                    ^
    <source>:7:20: note: 'U' is not literal because it has data member 'tail_'
of non-literal type 'nonliteral'
            nonliteral tail_;
                       ^
    1 error generated.

This impacts usage of std::variant with a mix of literal and non-literal types
in a constant expression.

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

Reply via email to