[LLVMbugs] [Bug 21010] New: incorrect result for is_trivially_copyable on class with deleted destructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Sep 20 03:22:02 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21010

            Bug ID: 21010
           Summary: incorrect result for is_trivially_copyable on class
                    with deleted destructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mizvekov at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following example results in is_trivially_copyable being true while it
should be false:

#include <iostream>
#include <type_traits>

struct foo {
    int bar;
    ~foo() = delete;
};

int main() {
    std::cout << std::is_trivially_copyable<foo>::value << std::endl;
    return 0;
}

The problem is that clang checks if the class has no non-trivial destructors,
instead of checking if it has a trivial destructor, an important distinction.

Consider how trivially copyable is defined in the draft standard:

    A trivially copyable class is a class that:
    — has no non-trivial copy constructors (12.8),
    — has no non-trivial move constructors (12.8),
    — has no non-trivial copy assignment operators (13.5.3, 12.8),
    — has no non-trivial move assignment operators (13.5.3, 12.8), and
    — has a trivial destructor (12.4).

Note the last bullet point. So clearly 'foo' should not be trivially copyable,
because it has no trivial destructor, since it was deleted.

-- 
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/20140920/668e5da8/attachment.html>


More information about the llvm-bugs mailing list