[LLVMbugs] [Bug 15307] New: Incorrect "Assigned value is always the same as the existing value"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 19 17:28:59 PST 2013


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

            Bug ID: 15307
           Summary: Incorrect "Assigned value is always the same as the
                    existing value"
           Product: clang
           Version: 3.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: mwelinder at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

It appears that the static analyzer doesn't understand C structure
copies.  The warning below would be correct without the "*a = *b;"
statement.

typedef struct {
  int x;
  int y;
} bar;

void
foo (bar *a, bar *b)
{
  int x;

  x = a->x;
  *a = *b;
  a->x = x;
}


welinder at anemone ~ $ scan-build -v make aaa.o
scan-build: 'clang' executable not found in '/usr/share/clang/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/bin/clang
scan-build: Emitting reports for this run to '/tmp/scan-build-2013-02-19-5'.
/usr/share/clang/scan-build/ccc-analyzer    -c -o aaa.o aaa.c
aaa.c:13:8: warning: Assigned value is always the same as the existing value
  a->x = x;
  ~~~~ ^ ~
1 warning generated.
scan-build: 1 bugs found.

welinder at anemone ~ $ clang --version
Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

-- 
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/20130220/6b66c539/attachment.html>


More information about the llvm-bugs mailing list