[llvm-bugs] [Bug 41345] New: invalid operations on forward iterators

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 2 05:40:41 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41345

            Bug ID: 41345
           Summary: invalid operations on forward iterators
           Product: parallel STL
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: New
          Assignee: ldionne at apple.com
          Reporter: zilla at kayari.org
                CC: llvm-bugs at lists.llvm.org

There are several objects that are declared as _ForwardIterator but are used as
random access iterators e.g. in __internal::__remove_elements

    _DifferenceType __n = __last - __first;

and

                __calc_mask(__mask + __i, __mask + __j, __first + __i);

Similarly, __brick_reverse does this on _BidirectionalIterator objects:

    const auto __n = (__last - __first) / 2;


Those can be fixed by using std::distance and std::next, but there are other
uses of objects declared _ForwardIterator which are only valid for
bidirectional iterators e.g. in __pattern_unique:

    return remove_elements(
        std::forward<_ExecutionPolicy>(__exec), ++__first, __last,
        [&__pred, __is_vector](bool* __b, bool* __e, _ForwardIterator __it) {
            __brick_walk3(__b, __e, __it - 1, __it,

And several functions call __unseq_backend::__simd_walk_2 with _ForwardIterator
or _BidirectionalIterator arguments, when __simd_walk_2 assumes random access
iterators.

These are harder to fix.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190402/7bc2ea1a/attachment.html>


More information about the llvm-bugs mailing list