On 17 January 2013 07:53, Daniel Krügler <daniel.krueg...@gmail.com> wrote: > 2013/1/17 Jonathan Wakely <jwakely....@gmail.com>: >> 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? > > Isn't here a typedef missing: > > + /* The target's "set" value for test-and-set may not be exactly 1. */ > +#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1 > + typedef bool __atomic_flag_data_type; > +#else > + unsigned char __atomic_flag_data_type; > +#endif
Gah! quite right, thanks. I'll try to find a target to test it on where the set value isn't 1, just to be sure it works.