[LLVMbugs] [Bug 22877] New: Missing destructors for default arguments created during list-initialization of array
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Mar 11 15:31:28 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=22877
Bug ID: 22877
Summary: Missing destructors for default arguments created
during list-initialization of array
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: zilla at kayari.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
From
http://stackoverflow.com/questions/28991043/why-does-clang-destroy-only-one-foo-object
extern "C" int puts(const char*);
struct foo {
int* n;
foo() : n(new int) { puts("cons"); }
~foo() { puts("dest"); delete n; }
foo(foo&& f) : n(f.n) { f.n = 0; }
};
struct bar {
bar(foo t=foo{}) { }
};
int main() {
bar b[3]{};
}
clang++ -std=c++11 leak.cc -fsanitize=address
The program prints
cons
cons
cons
dest
=================================================================
==11813==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 2 object(s) allocated from:
#0 0x4eae5b in operator new(unsigned long)
/home/jwakely/src/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:62:35
#1 0x4ec178 in foo::foo() /tmp/leak.cc:5:15
#2 0x4ebdfc in main /tmp/leak.cc:15:14
#3 0x3236e21d64 in __libc_start_main (/lib64/libc.so.6+0x3236e21d64)
SUMMARY: AddressSanitizer: 8 byte(s) leaked in 2 allocation(s).
The expected output is:
cons
dest
cons
dest
cons
dest
This is with:
clang version 3.7.0 (trunk 229722) (llvm/trunk 229719)
Target: x86_64-unknown-linux-gnu
Thread model: posix
--
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/20150311/404de219/attachment.html>
More information about the llvm-bugs
mailing list