LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 33040 - Destructors not called for temporaries created during array initialization
Summary: Destructors not called for temporaries created during array initialization
Status: RESOLVED DUPLICATE of bug 22877
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-15 08:03 PDT by Tim Northover
Modified: 2017-05-15 08:59 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Northover 2017-05-15 08:03:41 PDT
Spotted by Adam Nowacki, and it certainly looks dodgy to me. Only one of the objects gets destroyed in the following code:

#include <stdio.h>
struct A {
  ~A() {
    printf("Destroying\n");
  }
};
A make_a() {
  return A();
}
struct B {
    B(A a = make_a()) {};
};

int main() {
    B b[5] = {};
}
Comment 1 Richard Smith 2017-05-15 08:59:05 PDT

*** This bug has been marked as a duplicate of bug 22877 ***