[LLVMbugs] [Bug 8670] Optimization causes incorrect output.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 22 21:19:20 PST 2010


Chris Lattner <clattner at apple.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Chris Lattner <clattner at apple.com> 2010-11-22 23:19:20 CST ---
It's not obvious, but this is because your program has undefined behavior. 
This line:

    struct IntContainer *a =
          (void *)((char *)(list->next) -
                   ((char *)&a->link - (char *)(a)));

contains a dereference of a->link before a is set.  Since a contains an
uninitialized variable, a->link and a are not guaranteed to have related

This is more complex but equivalent to:

int a;

which is not guaranteed to print zero.

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