[LLVMbugs] [Bug 13927] New: offsetof replacement macro flagged as "dereference of a null pointer"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 26 04:52:40 PDT 2012


             Bug #: 13927
           Summary: offsetof replacement macro flagged as "dereference of
                    a null pointer"
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: magnus.reftel at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Since sometime between r164412 and r164453, the following code (which may be
odd but follows a pattern commonly generated by macro reimplementations of
offsetof, e.g. APR_OFFSET) is flagged as a dereference of a null pointer by the
Clang Static Analyzer:

#include <stddef.h>

struct S {
        int i;

ptrdiff_t offset_of_i(void)
        return ((char *)&(((struct S*)0)->i)) - ((char *)0);

While this might not be good code, its use by library macros can make it hard
to eliminate it from client code.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list