C++ Logo

std-discussion

Advanced search

Re: CWG710 and races during object construction

From: Jason Cobb <jason.e.cobb_at_[hidden]>
Date: Thu, 11 Feb 2021 13:25:59 -0500
On 2/11/21 1:15 PM, Giuseppe D'Angelo via Std-Discussion wrote:
> Hi,
>
> On 11/02/2021 19:05, Jason Cobb via Std-Discussion wrote:
>> I think [0] has you covered for UB in case 1. The typeid does not
>> happen-before the destruction of the global, so it's UB to pass the
>> glvalue to typeid.
>>
>>
>> [0]:https://eel.is/c++draft/basic.life#7.4
> I'm not sure; doesn't that entire sentence (the four bullet point) refer
> to the "Otherwise" case above (I.e. object is not under construction or
> destruction)? Otherwise, does something like 7.2 mean you can't call a
> non-static member function on *this from a constructor?


Right, if it happened-before the end of the constructor (when not in the
"Otherwise" case), [0] applies. But if it doesn't happen-before the end
of the constructor, [1] still applies.

(Disclaimer: I'm an idiot and this could all be very wrong.)

[0]: https://eel.is/c++draft/class.cdtor#5.sentence-2

[1]: https://eel.is/c++draft/basic.life#7.4

-- 
Jason Cobb

Received on 2021-02-11 12:26:03