From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12175 invoked by alias); 2 Feb 2012 23:26:42 -0000 Received: (qmail 12162 invoked by uid 22791); 2 Feb 2012 23:26:41 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from trmail.triumf.ca (HELO trmail.triumf.ca) (142.90.100.150) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Feb 2012 23:26:27 +0000 Received: from [142.90.148.23] (edevel23pc.ggeng.triumf.ca [142.90.148.23]) by trmail.triumf.ca (8.13.8/8.13.8) with ESMTP id q12NQNUp009959; Thu, 2 Feb 2012 15:26:24 -0800 Message-ID: <4F2B1C36.6010404@triumf.ca> Date: Thu, 02 Feb 2012 23:26:00 -0000 From: Rod Nussbaumer User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.16) Gecko/20101123 SeaMonkey/2.0.11 MIME-Version: 1.0 To: Richard Koch CC: crossgcc@sourceware.org Subject: Re: Compiler Memory Alignment Issue References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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/msg00031.txt.bz2 Richard: It probably doesn't cause the result you're seeing, but the size of your buffer[] (8 bytes) is one byte smaller than that which you are reading and printing (9 bytes: 0 - 8). > PROGRAM: > > #include > #include > #include > #include > > int main() > { > unsigned char buffer[8], i; > int *ptr = (int *) buffer; > > printf("size of int is: %d\n", sizeof(int)); > memset(buffer, 0xff, sizeof buffer); > > *(ptr + 1) = 0x1234; > > for (i=0; i<(sizeof(buffer) +1); i++) > printf("buffer[%d]=%x\n", i, buffer[i]); > } > > -- For unsubscribe information see http://sourceware.org/lists.html#faq