[Bug c++/82560] [7/8 Regression] Temporary object created as a default argument not destructed
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Oct 16 11:06:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82560
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Known to work| |6.4.0
Keywords| |wrong-code
Last reconfirmed| |2017-10-16
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=49372
Ever confirmed|0 |1
Summary|Temporary object created as |[7/8 Regression] Temporary
|a default argument not |object created as a default
|destructed |argument not destructed
Target Milestone|--- |7.3
Known to fail| |7.2.0, 8.0
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed:
extern "C" int printf(const char*, ...);
struct Foo {
Foo(const char *) {
printf("%p\tFoo(const char*)\n", this);
}
Foo(const Foo&) {
printf("%p\tFoo(const Foo&)\n", this);
}
~Foo() {
printf("%p\t~Foo()\n", this);
}
};
struct Bar {
Bar(Foo foo = "implicitly casted to Foo") : foo_(foo) {
printf("%p\tBar(Foo)\n", this);
}
~Bar() {
printf("%p\t~Bar()\n", this);
}
Foo foo_;
};
template<typename T>
struct unique_ptr
{
unique_ptr(T* p) : p(p) { }
~unique_ptr() { delete p; }
T* p;
};
int main()
{
{
printf("OK:\n");
unique_ptr<Bar> p1(new Bar);
}
{
printf("Wrong:\n");
unique_ptr<Bar> p2(new Bar());
}
}
More information about the Gcc-bugs
mailing list