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

Reply via email to