[LLVMbugs] [Bug 21908] New: Detect unnecessary postfix ++ or --

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Dec 13 10:01:25 PST 2014


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

            Bug ID: 21908
           Summary: Detect unnecessary postfix ++ or --
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: legalize at xmission.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In code like this:

 1:    i = 32767 + read_help_topic(INTRO_AUTHORS, 0, 32767, screen_text);
 2:    screen_text[i++] = '\0';
 3:    i = 32767 + read_help_topic(INTRO_CREDITS, 0, 32767, credits);
 4:    credits[i++] = '\0';
 5:
 6:    j = 0;
 7:    authors.push_back(0);               /* find the start of each
credit-line */
 8:    for (i = 0; credits[i] != 0; i++)
 9:        if (credits[i] == 10)
10:            authors.push_back(i+1);
11:    authors.push_back(i);

The postfix ++ applied on lines 2 and 4 result in a modification to i that is
never read, but deadcode.DeadStores doesn't report this.

See attached source, lines 40-43 in intro.cpp

-- 
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/20141213/7764b7c5/attachment.html>


More information about the llvm-bugs mailing list