[LLVMbugs] [Bug 7297] New: Member access is not the same for b[0].x and b->x

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 3 21:02:15 PDT 2010


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

           Summary: Member access is not the same for b[0].x and b->x
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: jediknil at belkadan.com
                CC: llvmbugs at cs.uiuc.edu


If I have a pointer (p) to a struct on the stack (a), setting a field using
p->x or a.x does not affect p[0].x, or vice versa. The test case below says
p[0].x is a garbage value.

Reminiscent of and possibly related to PR7218.

---

#define FAIL ((void)*(char*)0)
struct simple { int x; };

void test () {
  struct simple a;
  struct simple *p = &a;
  p->x = 5;
  if (!p[0].x) FAIL; // no-warning
  if (p[0].x) FAIL; // expected-warning {{null}}
}

-- 
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