The background is in this question of mine. Put shortly, I have to fork
in a multithreaded C++ program, so I\'d like to figure out how much I can do when r
I've looked at both the gcc
libsupc++ and clang
libc++ source, for replacing the standard-conforming C++ new/delete operators - to support native SIMD alignment requirements on platforms where it wasn't guaranteed by malloc
.
They are basically wrappers for malloc
and free
with some EH logic, etc. I am not a language lawyer, but unless both have it wrong, I think it's safe to conclude: no, they are not reentrant.
Standard allows new
to be just a wrapper around malloc
, so if malloc
can be not reentrant, so can new
.
Thread-safety and re-entrance are not exactly the same.
AFAIK, the C++ ISO standard does not guarantee thread-safety for new
and delete
operators. But g++
implementation does provide thread-safetly (and it's one of the reasons it's slow).