[LLVMbugs] [Bug 16476] New: If an array element lifetime-extends a temporary, we destroy the objects in the wrong order
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jun 27 16:13:34 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16476
Bug ID: 16476
Summary: If an array element lifetime-extends a temporary, we
destroy the objects in the wrong order
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: richard-llvm at metafoo.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Consider:
struct A { ~A(); };
struct B { const A &a; ~B(); };
void f() { B b[2] = { A(), A() }; }
The 'A' objects are lifetime-extended here. Since we are supposed to clean up
automatic objects in reverse construction order (and C++11 sequences list
initialization), we should call:
~B() for b[0]
~A() for b[0]'s temporary
~B() for b[1]
~A() for b[1]'s temporary
However, clang emits a cleanup for the B[2] array instead, and so destroys both
B objects before either A object.
--
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/20130627/17f299f1/attachment.html>
More information about the llvm-bugs
mailing list