This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] fix libstdc++/56012 - narrowing conversion in std::atomic_flag


This fixes a regression since 4.6 when -Wsystem-headers is used.  The
initialization of the __atomic_flag_base base class has a narrowing
conversion from int (the macro) to either bool or unsigned char.  The
patch fixes it by calling a constexpr function which implicitly
converts the value to the return type instead of doing the conversion
inside a braced-init-list.  Doing that requires naming the return
type, so I defined a new typedef for to avoid duplicating the
preprocessor conditional.  The patch also adds a missing assignment
operator in atomic<bool>.

        PR libstdc++/56012
        * include/bits/atomic_base.h (atomic_flag): Fix narrowing conversion.
        * testsuite/29_atomics/atomic/operators/56012.cc: New.

        PR libstdc++/56011
        * include/std/atomic (atomic<bool>::operator=(bool) volatile): Add
        missing overload.
        * testsuite/29_atomics/atomic/operators/56011.cc: New.

Tested x86_64-linux, it's a regression so I want to commit it to the
trunk and 4.7 branch, any objections from the atomics experts?

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]