Vincent Lefevre <vinc...@vinc17.net> writes: On 2018-03-12 18:53:37 +0100, Marco Bodrato wrote: > double > mpz_get_d (const mpz_t u) > { > static int c = 0; > static int __initialized = 0; > > if (__initialized != 1) { > c = gmp_tests_dbl_mant_bits (); > *((volatile int *) &__initialized) = 1; > }
FYI, this is not thread-safe. I suppose the externally visible store order is not guaranteed to be the same as the program store order, not even with "volatile". One variable, declared as volatile, should work fine though. Of course, that assumes some value for the variable can be used to represent a non-initialised state. For c above, 0 seems to be a useable value as no floating-point format with zero mantissa bits has yet been invented. -- Torbjörn Please encrypt, key id 0xC8601622 _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel