C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Relax condition for potentially invoked destructor in constructor

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Thu, 24 Feb 2022 20:02:30 -0500
On Thu, Feb 24, 2022 at 6:40 PM organicoman via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hmm,
> That means that tglhe following code will print nonsense.
>
> struct foo
> {
> foo()=delete;
> foo(int _a) : a(_a) { printf("foo%d\n",a);}
> };
>

Here, `foo` has no member named `a`, so this won't compile.
You can use https://godbolt.org/ to test out your C++ code and see what it
prints. I think you'll find that the behavior is pretty much sensible and
exactly what you'd expect in context. (There *are* some corner cases around
what happens with the construction of multiply inherited virtual bases, but
that's a super corner case. See
https://quuxplusone.github.io/blog/2019/09/30/what-is-the-vtt/ for the gory
details.)

–Arthur

Received on 2022-02-25 01:02:42