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

            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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to