This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20099] -pthreads should imply -fno-threadsafe-statics
- From: "qrczak at knm dot org dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Feb 2005 01:53:55 -0000
- Subject: [Bug c++/20099] -pthreads should imply -fno-threadsafe-statics
- References: <20050220004607.20099.davids@webmaster.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From qrczak at knm dot org dot pl 2005-02-23 01:53 -------
> The '-pthreads' flag should imply '-fno-threadsafe-statics'. For every other
> similar flag I can find, the default is to permit the compiler to make the
> optimizations that standard allows and specific flags are needed to disable the
> optimization.
It's not the question of optimization but correctness. Having an "initialize on
first use" semantics which breaks when multiple threads use it is as wrong as
using global variables for passing data between functions and forcing clients to
introduce locks to make them reentrant. It is usable when clients are careful,
but it's a bad default when we can't expect all calls to be done from a single
thread.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20099