Fix undefined behavior in syntax_option_type::operator~ and match_flag_type::operator./a.out Found by UBSan

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@177693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow 2013-03-22 02:13:55 +00:00
parent bdea27ba8f
commit 04bd79b23a

View File

@ -764,7 +764,7 @@ _LIBCPP_CONSTEXPR
syntax_option_type syntax_option_type
operator~(syntax_option_type __x) operator~(syntax_option_type __x)
{ {
return syntax_option_type(~int(__x)); return syntax_option_type(~int(__x) & 0x1FF);
} }
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@ -840,7 +840,7 @@ _LIBCPP_CONSTEXPR
match_flag_type match_flag_type
operator~(match_flag_type __x) operator~(match_flag_type __x)
{ {
return match_flag_type(~int(__x)); return match_flag_type(~int(__x) & 0x0FFF);
} }
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY