http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49158

           Summary: Incorrect pointer arithmetic with negative offset
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: a...@os.inf.tu-dresden.de


Created attachment 24353
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24353
The source code triggering the bug

The compiler generates incorrect code for pointer arithmetic on an external
array of structures.
When you use 'array[-1] = x' the target addresses are correct when you use
'*(array -1) = x' the addresses are sizeof(void*) too low.

I tested the code for x86 and x86_64 both are affected

affected compiler version:
g++ (Debian 4.6.0-9) 4.6.1 20110524 (prerelease)
g++ 4.7.0, 4.6.0

works with: g++ 4.5.2

test.cc provides the source code, test.S generated with:
g++ -S -fverbose-asm -o test.S test.cc
shows the two inconsistent code snippets before and after the comment (#
comment from me).

Reply via email to