[Bug c++/20099] -pthreads should imply -fno-threadsafe-statics

davids at webmaster dot com gcc-bugzilla@gcc.gnu.org
Fri Feb 25 01:37:00 GMT 2005


------- Additional Comments From davids at webmaster dot com  2005-02-24 20:42 -------
>The only thing which would change when you remove the automatically
>inserted locking is that some programs which used to work are now
>broken, and that some other programs which used to deadlock now
>invoke undefined behavior from entering an initializer recursively.

First, if we're talking about pthreads programs, which is the only case I'm
suggesting removing the locking for, then those programs are already broken. The
pthreads standard requires locks when data may be changed in one thread and
accessed in another. Entering an initializer recursively has always been
undefined behavior. Any code that might do that is broken.

In any event, the entire thrust of this argument is bogus. If GCC/G++ are
going to have non-portable features that make code work when they're enabled
and break when they're disabled, they definitely should not be on by
default. That they hide bugs in code that claims standards compliance on
one platform, but allow them to fail on another, is an argument *against* the
option, not for it. (Or are you seriously arguing that the C++ standard and the
POSIX standard *require* this behavior?)



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20099



More information about the Gcc-bugs mailing list