mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libstdc++: Protect PSTL headers against overloaded commas
Reported upstream: https://github.com/uxlfoundation/oneDPL/issues/2342 libstdc++-v3/ChangeLog: * include/pstl/algorithm_impl.h (__for_each_n_it_serial): Protect against overloaded comma operator. (__brick_walk2): Likewise. (__brick_walk2_n): Likewise. (__brick_walk3): Likewise. (__brick_move_destroy::operator()): Likewise. (__brick_calc_mask_1): Likewise. (__brick_copy_by_mask): Likewise. (__brick_partition_by_mask): Likewise. (__brick_calc_mask_2): Likewise. (__brick_reverse): Likewise. (__pattern_partial_sort_copy): Likewise. * include/pstl/memory_impl.h (__brick_uninitialized_move): Likewise. (__brick_uninitialized_copy): Likewise. * include/pstl/numeric_impl.h (__brick_transform_scan): Likewise.
This commit is contained in:
committed by
Jonathan Wakely
parent
9b6b7fed78
commit
9c75032b40
@@ -79,7 +79,7 @@ template <class _ForwardIterator, class _Size, class _Function>
|
||||
_ForwardIterator
|
||||
__for_each_n_it_serial(_ForwardIterator __first, _Size __n, _Function __f)
|
||||
{
|
||||
for (; __n > 0; ++__first, --__n)
|
||||
for (; __n > 0; ++__first, (void) --__n)
|
||||
__f(__first);
|
||||
return __first;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ _ForwardIterator2
|
||||
__brick_walk2(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _Function __f,
|
||||
/*vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
__f(*__first1, *__first2);
|
||||
return __first2;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ _ForwardIterator2
|
||||
__brick_walk2_n(_ForwardIterator1 __first1, _Size __n, _ForwardIterator2 __first2, _Function __f,
|
||||
/*vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __n > 0; --__n, ++__first1, ++__first2)
|
||||
for (; __n > 0; --__n, (void) ++__first1, ++__first2)
|
||||
__f(*__first1, *__first2);
|
||||
return __first2;
|
||||
}
|
||||
@@ -364,7 +364,7 @@ _ForwardIterator3
|
||||
__brick_walk3(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
|
||||
_ForwardIterator3 __first3, _Function __f, /*vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, ++__first2, ++__first3)
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__first3)
|
||||
__f(*__first1, *__first2, *__first3);
|
||||
return __first3;
|
||||
}
|
||||
@@ -961,7 +961,7 @@ struct __brick_move_destroy
|
||||
{
|
||||
using _IteratorValueType = typename std::iterator_traits<_RandomAccessIterator1>::value_type;
|
||||
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
*__result = std::move(*__first);
|
||||
(*__first).~_IteratorValueType();
|
||||
@@ -1027,7 +1027,7 @@ __brick_calc_mask_1(_ForwardIterator __first, _ForwardIterator __last, bool* __r
|
||||
static_assert(__are_random_access_iterators<_ForwardIterator>::value,
|
||||
"Pattern-brick error. Should be a random access iterator.");
|
||||
|
||||
for (; __first != __last; ++__first, ++__mask)
|
||||
for (; __first != __last; ++__first, (void) ++__mask)
|
||||
{
|
||||
*__mask = __pred(*__first);
|
||||
if (*__mask)
|
||||
@@ -1052,7 +1052,7 @@ void
|
||||
__brick_copy_by_mask(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, bool* __mask,
|
||||
_Assigner __assigner, /*vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__mask)
|
||||
for (; __first != __last; ++__first, (void) ++__mask)
|
||||
{
|
||||
if (*__mask)
|
||||
{
|
||||
@@ -1079,7 +1079,7 @@ void
|
||||
__brick_partition_by_mask(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator1 __out_true,
|
||||
_OutputIterator2 __out_false, bool* __mask, /*vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__mask)
|
||||
for (; __first != __last; ++__first, (void) ++__mask)
|
||||
{
|
||||
if (*__mask)
|
||||
{
|
||||
@@ -1383,7 +1383,7 @@ __brick_calc_mask_2(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_BinaryPredicate __pred, /*vector=*/std::false_type) noexcept
|
||||
{
|
||||
_DifferenceType __count = 0;
|
||||
for (; __first != __last; ++__first, ++__mask)
|
||||
for (; __first != __last; ++__first, (void) ++__mask)
|
||||
{
|
||||
*__mask = !__pred(*__first, *(__first - 1));
|
||||
__count += *__mask;
|
||||
@@ -1483,7 +1483,7 @@ void
|
||||
__brick_reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, _BidirectionalIterator __d_last,
|
||||
/*is_vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (--__d_last; __first != __last; ++__first, --__d_last)
|
||||
for (--__d_last; __first != __last; ++__first, (void) --__d_last)
|
||||
{
|
||||
using std::iter_swap;
|
||||
iter_swap(__first, __d_last);
|
||||
@@ -2333,7 +2333,7 @@ __pattern_partial_sort_copy(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&&
|
||||
_RandomAccessIterator1 __it = __first + (__i - __r);
|
||||
|
||||
// 1. Copy elements from input to raw memory
|
||||
for (_T1* __k = __i; __k != __j; ++__k, ++__it)
|
||||
for (_T1* __k = __i; __k != __j; ++__k, (void) ++__it)
|
||||
{
|
||||
::new (__k) _T2(*__it);
|
||||
}
|
||||
@@ -3648,7 +3648,7 @@ __mismatch_serial(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _Forwar
|
||||
#if defined(_PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT)
|
||||
return std::mismatch(__first1, __last1, __first2, __last2, __pred);
|
||||
#else
|
||||
for (; __first1 != __last1 && __first2 != __last2 && __pred(*__first1, *__first2); ++__first1, ++__first2)
|
||||
for (; __first1 != __last1 && __first2 != __last2 && __pred(*__first1, *__first2); ++__first1, (void) ++__first2)
|
||||
{
|
||||
}
|
||||
return std::make_pair(__first1, __first2);
|
||||
|
||||
@@ -29,7 +29,7 @@ __brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _O
|
||||
/*vector=*/std::false_type) noexcept
|
||||
{
|
||||
using _ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
::new (std::addressof(*__result)) _ValueType(std::move(*__first));
|
||||
}
|
||||
@@ -80,7 +80,7 @@ __brick_uninitialized_copy(_ForwardIterator __first, _ForwardIterator __last, _O
|
||||
/*vector=*/std::false_type) noexcept
|
||||
{
|
||||
using _ValueType = typename std::iterator_traits<_OutputIterator>::value_type;
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
::new (std::addressof(*__result)) _ValueType(*__first);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ __brick_transform_scan(_ForwardIterator __first, _ForwardIterator __last, _Outpu
|
||||
_UnaryOperation __unary_op, _Tp __init, _BinaryOperation __binary_op,
|
||||
/*Inclusive*/ std::false_type, /*is_vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
_Tp __v = std::move(__init);
|
||||
_PSTL_PRAGMA_FORCEINLINE
|
||||
@@ -175,7 +175,7 @@ __brick_transform_scan(_RandomAccessIterator __first, _RandomAccessIterator __la
|
||||
_UnaryOperation __unary_op, _Tp __init, _BinaryOperation __binary_op,
|
||||
/*Inclusive*/ std::true_type, /*is_vector=*/std::false_type) noexcept
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__result)
|
||||
for (; __first != __last; ++__first, (void) ++__result)
|
||||
{
|
||||
_PSTL_PRAGMA_FORCEINLINE
|
||||
__init = __binary_op(__init, __unary_op(*__first));
|
||||
|
||||
Reference in New Issue
Block a user