[llvm-bugs] [Bug 36651] New: Undefined behavior in SmallVector implementation
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 8 08:50:44 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36651
Bug ID: 36651
Summary: Undefined behavior in SmallVector implementation
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Core LLVM classes
Assignee: unassignedbugs at nondot.org
Reporter: tstellar at redhat.com
CC: llvm-bugs at lists.llvm.org
Compiling with gcc 8 gives lots of warnings like:
/builddir/build/BUILD/llvm-6.0.0rc2.src/include/llvm/ADT/SmallVector.h:299:13:
warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of
type 'struct std::pair<const llvm::MCSymbol*, const llvm::MCSymbol*>' with no
trivial copy-assignment; use copy-assignment or copy-initialization instead
[-Wclass-memaccess]
memcpy(Dest, I, (E - I) * sizeof(T));
This is undefined behavior, which can be fixed by using:
std::uninitialized_copy(), or maybe more optimally by first checking if T is
trivially copy-able. However, this code is only supposed to be called on POD
types, so there may be a bug somewhere else that is causing non-POD types to go
down this path.
--
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/20180308/0e2111ab/attachment.html>
More information about the llvm-bugs
mailing list