From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25915 invoked by alias); 2 Feb 2012 18:15:29 -0000 Received: (qmail 25858 invoked by uid 22791); 2 Feb 2012 18:15:28 -0000 X-SWARE-Spam-Status: No, hits=0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snt0-omc3-s7.snt0.hotmail.com (HELO snt0-omc3-s7.snt0.hotmail.com) (65.55.90.146) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Feb 2012 18:15:13 +0000 Received: from SNT112-W20 ([65.55.90.137]) by snt0-omc3-s7.snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 2 Feb 2012 10:15:11 -0800 Message-ID: From: Richard Koch To: Subject: Compiler Memory Alignment Issue Date: Thu, 02 Feb 2012 18:15:00 -0000 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00027.txt.bz2 Hello List, I'm seeing an alignment issue when I'm incrementing a pointer. Using the program below I found that the cross compiler I built from crosstools-ng-1.13.3, interprets the "*(ptr + 1)" as adding 1 BYTE to ptr. = It should know that ptr is declared as a pointer to an integer and interpret "*(ptr += 1)" as adding 4 BYTES to ptr. An older cross compiler from Technologics, crosstool-linux-gnueabi-2005q3-2= , doesn't exhibit this problem and interprets the pointer addition correctly. So does= the native gcc on the target. I would prefer to use crosstools-ng. The target is a Technologics TS-7350 ARM920T (EP9302). I'm wondering if there may be something I haven't set properly in the cross= tool-ng's configuration? The configuration file I'm using can be seen here: =A0=A0=A0 http://home.comcast.net/~n1gp/ct_config PROGRAM: #include #include #include #include int main() { =A0=A0=A0=A0=A0=A0=A0 unsigned char buffer[8], i; =A0=A0=A0=A0=A0=A0=A0 int *ptr =3D (int *) buffer; =A0=A0=A0=A0=A0=A0=A0 printf("size of int is: %d\n", sizeof(int)); =A0=A0=A0=A0=A0=A0=A0 memset(buffer, 0xff, sizeof buffer); =A0=A0=A0=A0=A0=A0=A0 *(ptr + 1) =3D 0x1234; =A0=A0=A0=A0=A0=A0=A0 for (i=3D0; i<(sizeof(buffer) +1); i++) =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 printf("buffer[%d]=3D%x\n", i= , buffer[i]); } RESULTS WITH crosstool-linux-gnueabi-2005q3-2: size of int is: 4 buffer[0]=3Dff buffer[1]=3Dff buffer[2]=3Dff buffer[3]=3Dff buffer[4]=3D34 buffer[5]=3D12 buffer[6]=3D0 buffer[7]=3D0 buffer[8]=3D0 RESULTS WITH crosstools-ng: size of int is: 4 buffer[0]=3Dff buffer[1]=3D34 buffer[2]=3D12 buffer[3]=3D0 buffer[4]=3D0 buffer[5]=3Dff buffer[6]=3Dff buffer[7]=3Dff buffer[8]=3D8 Thanks, Rick =20=09=09=20=09=20=20=20=09=09=20=20 -- For unsubscribe information see http://sourceware.org/lists.html#faq