Question about __gnu_cxx::__exchange_and_add_dispatch
Jonathan Wakely
jwakely@redhat.com
Fri Apr 21 08:49:07 GMT 2023
On Fri, 21 Apr 2023 at 08:06, unlvsur unlvsur via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Take this as an example
> gcc/ios_init.cc at master · gcc-mirror/gcc (github.com)<https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/src/c++98/ios_init.cc#L80>
>
>
> what happens when
> if (__gnu_cxx::__exchange_and_add_dispatch(&_S_refcount, 1) != 0??
>
> Does that mean global objects of iostream are not initialized?)
If _S_refcount != 0 that means the global iostreams have already been
initialized.
> Probably this is why I get crashing on windows since never (__gnu_cxx::__exchange_and_add_dispatch(&_S_refcount, 1) == 0
> With win32 thread model any more
That _S_refcount object has static storage duration, so it should be
initialized to zero before the program starts executing.
If static data isn't being zeroed that yes, that will cause big problems.
> However, if I use lld or statically link with ld, the program would still work. It does not when it dynamic link with ld.
More information about the Libstdc++
mailing list