[LLVMbugs] [Bug 18185] New: Deleted copy/assign considered "trivial" by __has_trivial_{copy, assign}

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Dec 8 23:22:04 PST 2013


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

            Bug ID: 18185
           Summary: Deleted copy/assign considered "trivial" by
                    __has_trivial_{copy,assign}
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: temporal at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Both static_asserts below fail on Clang but pass on GCC.

In my case, I incorrectly tried to copy a class with deleted copy and
assignment, but the code which actually performed the copy was a template that
used the type traits to decide when it could use memcpy instead as an
optimization.  So, instead of the expected compiler error I got silent memory
corruption.


struct S {
  S(const S&) = delete;
  S& operator=(const S&) = delete;
};

static_assert(!__has_trivial_copy(S),
    "Deleted copy constructor considered trivial.");
static_assert(!__has_trivial_assign(S),
    "Deleted operator= considered trivial.");

-- 
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/20131209/40c5df73/attachment.html>


More information about the llvm-bugs mailing list