C++ Logo

std-discussion

Advanced search

Unsynchronized placement-new

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Tue, 20 Dec 2022 00:40:36 -0500
[new.delete.dataraces] states that calling "the library versions of
operator new" is not a data race. It then goes on to talk about memory
allocation and deallocation.

But placement-new doesn't do allocation. And I cannot imagine how
performing placement-new from different threads on the same storage
isn't a data race.

Now, if the new expression that invokes placement-new involves
initialization, then yes, that does cause a data race with other
initializing placement-new operations on that storage. This is because
of the initialization operations conflicting by accessing the same
memory.

And while we're here, `start_lifetime_as` doesn't seem to have any
language about data races. So like... what does that mean?

Received on 2022-12-20 05:43:05