[llvm-bugs] [Bug 50740] New: __is_trivial doesn't work in the presence of special member functions with trailing requires clauses

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 16 08:44:02 PDT 2021


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

            Bug ID: 50740
           Summary: __is_trivial doesn't work in the presence of special
                    member functions with trailing requires clauses
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ldionne at apple.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

When compiled with Clang ToT, the following code incorrectly believes that
allocator<void> is non-trivial, when it should be trivial:

cat <<EOF | clang++ -xc++ - -std=c++2a -fsyntax-only
#include <type_traits>

template <class T>
struct allocator {
    allocator() = default;
    allocator() requires(!std::is_void_v<T>) { }
};

static_assert(__is_trivial(allocator<void>));

int main() { }
EOF

This works on GCC. Godbolt link: https://godbolt.org/z/4osMGWTne.

I tracked the issue down a bit, and  I think the issue is that when
QualType::isTrivialType() queries whether the class declaration has a
non-trivial default constructor (via
CXXRecordDecl::hasNonTrivialDefaultConstructor()), it incorrectly believes that
it's the case.

-- 
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/20210616/eca57e09/attachment.html>


More information about the llvm-bugs mailing list