[LLVMbugs] [Bug 19863] New: suspicious code in nth_element test

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 26 23:17:07 PDT 2014


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

            Bug ID: 19863
           Summary: suspicious code in nth_element test
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eric at boostpro.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

The test for nth_element has this:

void
test_one(unsigned N, unsigned M)
{
    assert(N != 0);
    assert(M < N);
    int* array = new int[N];
    for (int i = 0; i < N; ++i)
        array[i] = i;
    std::random_shuffle(array, array+N);
    std::nth_element(array, array+M, array+N);
    assert(array[M] == M);
    std::nth_element(array, array+N, array+N); // begin, end, end
    delete [] array;
}

I'm wondering about the final call to std::nth_element. Nothing is checked
after the call. What's the point? I'm tempted to think that the author had
something in mind (maybe assert(array[N] == N)), but forgot it.

So, not a bug report per se, just a red flag.

-- 
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/20140527/1806baa6/attachment.html>


More information about the llvm-bugs mailing list