The '-fno-threadsafe-statics' is purely a pessimization for POSIX pthreads code.
Since the POSIX standard already requires a mutex around operations that modify
data, and the C++ standard specifies lazy initialization, POSIX code will
already have mutexes to make static initialization thread safe. The code is,
therefore, already thread safe and cannot be made more so.

This option does allow non-compliant code to work by relaxing some of the
requirements in the POSIX standard. That's a good option to have, but it should
not be on by default. Code should, by default, get the benefit of the
optimizations the standard allows.

In summary, an option that is a pure pessimization for compliant code, and is
only required to make non-compliant code work, should not be on by default when
that standard is invoked. This is the case for other options in this category
(writable strings, relaxed aliasing, and so on).

So, '-pthreads' should imply '-fno-threadsafe-statics', and an option like
'-fthreadsafe-statics' should be created to request this option.

-- 
           Summary: -pthreads should imply -fno-threadsafe-statics
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: davids at webmaster dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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

Reply via email to