LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 39 - Casted pointer arithmetic not incremented correctly
Summary: Casted pointer arithmetic not incremented correctly
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Chris Lattner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-13 23:10 PDT by Chris Lattner
Modified: 2010-03-06 13:58 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2003-10-13 23:10:55 PDT
This bug was painstakenly reduced from 176.gcc, _manually_.  The C front-end
generates incorrect code for the increment here:

#include <stdio.h>

int main() {
        int Array[10];
        void *Pointer = &Array[0];
        unsigned i;

        for (i = 0; i < 10; ++i) {
                *((int*)Pointer)++ = 1234;
                printf("0x%d\n", (int)Pointer-(int)&Array[0]);
        }
}


This has been checked in as
test/Programs/SingleSource/Regression/C/2003-10-13-PointerIncrementTest.c
Comment 1 Chris Lattner 2003-10-13 23:39:57 PDT
This is now fixed.
Comment 2 Chris Lattner 2003-10-14 00:05:27 PDT
Oh btw, with this fix, 176.gcc now works with the C backend!