[LLVMbugs] [Bug 21018] New: "Dead assignment" false positive - ignores access through reference

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Sep 21 11:02:58 PDT 2014


            Bug ID: 21018
           Summary: "Dead assignment" false positive - ignores access
                    through reference
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: bgasowski+llvm at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

For this code (unused.cpp):

#include <iostream>

int main()
    int x = 1;
    int& ref = x;

    std::cout << ref << std::endl;
    x = 2;
    std::cout << ref << std::endl;

    return 0;

I get following output from scan-build:
unused.cpp:9:5: warning: Value stored to 'x' is never read
    x = 2;
    ^   ~
1 warning generated.

The value is obviously read, as second cout<<ref prints out 2, as expected.

My "clang++ --version":
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
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/20140921/fa81387f/attachment.html>

More information about the llvm-bugs mailing list