[llvm-bugs] [Bug 47926] New: Variable of dependent non-literal type in constexpr not correctly diagnosed

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 20 13:58:09 PDT 2020


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

            Bug ID: 47926
           Summary: Variable of dependent non-literal type in constexpr
                    not correctly diagnosed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          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

This TU:

    template <class T>
    constexpr bool f() {
        if (!__builtin_is_constant_evaluated()) {
            [[maybe_unused]] T t;
        }

        return true;
    }

    struct nonliteral {
        ~nonliteral() {}
    };

    static_assert(f<nonliteral>(), "should fail");

is ill-formed per N4868 [dcl.constexpr]/3.5.3 "The definition of a constexpr
function shall satisfy the following requirements:... its function-body shall
not enclose... a definition of a variable of non-literal type ...". Clang fails
to diagnose this TU (https://godbolt.org/z/xoMGxs).

-- 
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/20201020/c4f08355/attachment.html>


More information about the llvm-bugs mailing list