http://llvm.org/bugs/show_bug.cgi?id=17003
Bug ID: 17003
Summary: Gcc and clang differ in treatment of lifetime-extended
temporaries.
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
int main() {
struct A {
A() { printf("%p: A() \n", (void*)this); }
~A() { printf("%p: ~A() \n", (void*)this); }
A(const A&) = delete;
};
const A& a = 1 ? (const A &) A() : (const A &) A();
printf("Mark \n");
}
When I run the above code compiled with gcc-4.7, the destructor of A is run
after the printf("Mark") line, which means the lifetime of A was indeed
extended. However, clang (trunk) fails to do that (~A() is printed before
Mark).
I am not sure which interpretation is correct, but I am leaning towards gcc
one.
Also, if I remove the explicit const A& cast then clang complains about copy
constructor being deleted, while gcc still lifetime-extends the object (and
does not perform any copy, hopefully).
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs