From: Rod Nussbaumer <bomr@triumf.ca>
To: Richard Koch <n1gp@hotmail.com>
Cc: crossgcc@sourceware.org
Subject: Re: Compiler Memory Alignment Issue
Date: Thu, 02 Feb 2012 23:26:00 -0000 [thread overview]
Message-ID: <4F2B1C36.6010404@triumf.ca> (raw)
In-Reply-To: <SNT112-W20026C65DA2489BC8955CE87700@phx.gbl>
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<stdlib.h>
> #include<stdio.h>
> #include<string.h>
> #include<unistd.h>
>
> 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
next prev parent reply other threads:[~2012-02-02 23:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 18:15 Richard Koch
2012-02-02 23:09 ` Martin Guy
2012-02-02 23:26 ` Rod Nussbaumer [this message]
2012-02-03 9:52 ` Martin Guy
2012-02-03 10:16 ` Bob Dunlop
2012-02-03 13:21 ` Yann E. MORIN
2012-02-03 14:14 ` Johannes Stezenbach
2012-02-03 14:23 ` Yann E. MORIN
2012-02-03 20:41 ` Johannes Stezenbach
2012-02-03 15:13 ` Richard Koch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F2B1C36.6010404@triumf.ca \
--to=bomr@triumf.ca \
--cc=crossgcc@sourceware.org \
--cc=n1gp@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).