[LLVMbugs] [Bug 19338] New: False positive: reinterpret_cast<*> garbage or undefined assignment

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 4 01:50:06 PDT 2014


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

            Bug ID: 19338
           Summary: False positive: reinterpret_cast<*> garbage or
                    undefined assignment
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: spam at drgonzo.nl
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Analyzing the following program using the pre-built 'checker-276' available for
Mac OS X causes a false positive (Mac OS X 10.6.8 on a MacBook 1,1):

#include <arpa/inet.h>
#include <stdint.h>

int main() {
    uint32_t payload[2];
    payload[0] = htonl(0x01);
    payload[1] = htonl(0x01);

    uint8_t* bytes = new uint8_t[9];
    bytes[0] = 0x11;

    uint8_t* payloadBytes = reinterpret_cast<uint8_t*>(payload);
    for (size_t i = 0; i < 8; i++) {
        bytes[1 + i] = payloadBytes[i];
    }

    return 0;
}

The analyzer warning is:

test.cpp:14:16: warning: Assigned value is garbage or undefined
                bytes[1 + i] = payloadBytes[i];
                             ^ ~~~~~~~~~~~~~~~

-- 
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/20140404/196ed0d2/attachment.html>


More information about the llvm-bugs mailing list