[LLVMbugs] [Bug 15636] New: clang should warn on suspicious increments of loop variables

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 1 11:24:04 PDT 2013


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

            Bug ID: 15636
           Summary: clang should warn on suspicious increments of loop
                    variables
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: resistor at mac.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider the following code snippet:

void foo(char *a, char *b, unsigned c) {
    for (unsigned i = 0; i < c; ++i) {
        a[i] = b[i];
        ++i;
    }
}

clang does not currently warn on this, even though the code is likely incorrect
(incrementing i both in the loop latch and in the body of the loop).  clang
should produce a warning when it detects a variable that is incremented in the
latch of the for header, and *unconditionally* incremented in the body of the
loop.

-- 
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/20130401/93629e14/attachment.html>


More information about the llvm-bugs mailing list