This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++ and suppressing threadsafe-statics
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Klaus Doldinger <klaus dot doldinger64 at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 9 Oct 2019 10:19:15 +0100
- Subject: Re: g++ and suppressing threadsafe-statics
- References: <19e0dc94-16bb-92db-b4a4-019744c562a1@gmail.com>
On Wed, 9 Oct 2019 at 04:49, Klaus Doldinger wrote:
>
> Hi all,
>
> following is an example regarding the generation of guards for the
> static m in template X.
I didn't check the implementation, but according to the documentation,
-fno-threadsafe-statics only affects local static, so it's
unsurprising that it doesn't have any effect on a static member
variable.
For the local static variable, GCC and Clang still emit the guard
variable with -fno-threadsafe-statics but they do not emit the code to
use that variable (there are no calls to __cxa_guard_acquire or
__cxa_guard_release). I believe the guard variable stills gets be
emitted for ABI reasons, because another translation unit compiled
without -fno-threadsafe-statics might be expecting it to exist.