[Bug libstdc++/78552] New: std::locale::classic() Needless Race

gccbza at bluematt dot me gcc-bugzilla@gcc.gnu.org
Mon Nov 28 01:48:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78552

            Bug ID: 78552
           Summary: std::locale::classic() Needless Race
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbza at bluematt dot me
  Target Milestone: ---

I'm not sure whether the standard has any thread-safety requirements for
std::local::classic() (I cant seem to find any?), but it seems needlessly
race-y:

classic() constructs a new locale on top of the global c_locale using the
locale(_Impl*) constructor, which only bothers to set _M_impl to the pointer
passed in. Thus, every time you call classic() it sets c_locale._M_impl to
_S_classic and then returns a const reference to c_locale.

This isnt an issue on many (any?) platforms, but helgrind/drd gets very upset
and there is seemingly no reason to do this outside of _S_initialize?


More information about the Gcc-bugs mailing list