This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/71786] Constructor never called
- From: "guille at cal dot berkeley.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 07 Jul 2016 18:52:46 +0000
- Subject: [Bug c++/71786] Constructor never called
- Auto-submitted: auto-generated
- References: <bug-71786-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71786
--- Comment #4 from Guille <guille at cal dot berkeley.edu> ---
Hi Marc,
Thank you for your clarification.
I realized my initial problem arose in a slightly more complicated case
(below).
In this case a copy/move ctor of A is used, but this default-generated ctor
does not construct the base case B. Shouldn't default ctors automatically
construct base classes?
std::set<std::uintptr_t> all;
struct B
{
B()
{
all.insert((std::uintptr_t)this);
}
~B()
{
assert(all.find((std::uintptr_t)this) != all.end()); // FAILS
all.erase((std::uintptr_t)this);
}
};
struct A : B
{
A() : B() {}
// A(const A&) : B() {}
~A() {}
};
static std::experimental::optional<A> f()
{
A a;
return a;
}
int main()
{
auto a = f();
return 0;
}