https://bugs.llvm.org/show_bug.cgi?id=36992
Bug ID: 36992
Summary: copy constructor memcpy optimization tramples virtual
bases in tail padding
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: richard-l...@metafoo.co.uk
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
Testcase:
struct A { char c; A(const A&) : c(1) {} };
struct B { int n; char c[3]; ~B(); };
struct C : B, virtual A {}; C f(C c) { return c; }
The move constructor we emit for C performs an 8-byte memcpy to construct its B
base class, which tramples over the initialization we've already performed for
the A virtual base class.
Similar issues will arise when memcpyizing non-static data members due to P0840
-- http://wg21.link/p0840r2, or http://wg21.link/p0840r1 for the latest
publicly-visible version:
struct A { char c; A(const A&) : c(1) {} };
struct B { int n; char c[3]; ~B(); };
struct C : virtual A { [[no_unique_address]] B b; }; C f(C c) { return c; }
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs