http://llvm.org/bugs/show_bug.cgi?id=18786

            Bug ID: 18786
           Summary: Iterator overrun in std::unique
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Hi Howard. Forgive me, maybe this is just because I haven't had my morning
coffee yet, but I'm looking at the implementation of std::unique, and I see
this:

    if (__first != __last)
    {
        // ...  a  a  ?  ...
        //      f     i
        _ForwardIterator __i = __first;
        for (++__i; ++__i != __last;)
            if (!__pred(*__first, *__i))
                *++__first = _VSTD::move(*__i);
        ++__first;
    }

Now image __first and __last delimit a sequence of exactly one element. __first
!= __last is true, __i is assigned begin, is incremented once (so now it equals
__last), and is then incremented *again* before comparing it to last. This
looks like a bug to me.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to