[llvm-bugs] [Bug 40837] New: Implement CWG 2096

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 23 19:37:57 PST 2019


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: unassignedclangbugs at nondot.org
          Reporter: Casey at Carter.net
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190224/2f0d5ba8/attachment.html>


More information about the llvm-bugs mailing list