https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83802
Bug ID: 83802 Summary: Caller doesn't destroy default argument passed to a constructor Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pdziepak at quarnos dot org Target Milestone: --- Godbolt link: https://godbolt.org/g/fBbYgF When the following code is compiled with -std=c++17: struct foo { ~foo(); }; extern foo f; struct bar { bar(int, foo = f); }; void fn() { bar b(0); } ...the destructor of the copy of f passed to the bar's constructor is never called: fn(): pushq %rbp movq %rsp, %rbp subq $16, %rsp leaq -1(%rbp), %rdx leaq -2(%rbp), %rax movl $0, %esi movq %rax, %rdi call bar::bar(int, foo) nop leave ret