[libcxx] r185265 - Add operators to make launch a bitmask type. Searched all of the standard, and libc++ to see if this error occurred elsewhere and didn't see any other place. This fixes http://llvm.org/bugs/show_bug.cgi?id=16207

Howard Hinnant hhinnant at apple.com
Tue Jul 2 11:03:15 PDT 2013


On Jul 1, 2013, at 9:15 AM, Marshall Clow <mclow.lists at gmail.com> wrote:

> On Jun 29, 2013, at 11:38 AM, Howard Hinnant <hhinnant at apple.com> wrote:
> 
>> +inline _LIBCPP_INLINE_VISIBILITY
>> +_LIBCPP_CONSTEXPR
>> +launch
>> +operator~(launch __x)
>> +{
>> +    return static_cast<launch>(~static_cast<__launch_underlying_type>(__x));
>> +}
> 
> This may cause problems down the line, because it sets bits in launch that are not defined to have any meaning.
> I ran into this kind of stuff when trying to use UBSan.
> 
> To prevent this problem, you can AND the result with 3, clearing all the unused bits.
> 
>> +    return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3);
> 
> (Yeah, I hate the naked '3' there too.)
> 
> -- Marshall
> 
> Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>
> 
> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
>        -- Yu Suzuki
> 

Thanks!

Committed revision 185452.

Howard




More information about the cfe-commits mailing list