public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Mailaripillai, Kannan Jeganathan" <kannanmj@hp.com>
To: Bernard Leak <bernard@brenda-arkle.me.uk>,
	"gcc-help@gcc.gnu.org"	<gcc-help@gcc.gnu.org>
Subject: RE: no warning even with -Wcast-align in windows/hp-ux
Date: Tue, 05 Mar 2013 03:53:00 -0000	[thread overview]
Message-ID: <AA6ADB5A789EDD4DA355F183E8ECDFA675278110@G4W3213.americas.hpqcorp.net> (raw)
In-Reply-To: <51350B9A.20602@brenda-arkle.me.uk>

> Do you *know* that char1, char2 are not both on appropriately-aligned 
> int boundaries?
Sorry. That was a incorrect example. Consider this:

  struct st1{
    char c1, c2, c3, c4, c5;
  } ob1;
  int main(void) {
    int *ip;
    ip = &ob1.c1; // c1 at 404100 in cygwin
    ip = &ob1.c2; // c2 at 404101 in cygwin
  }

> misaligned accesses to ints are not prohibited on. e.g., x86.
Right. No abort / bus error for misaligned int ptr (value) access.

> It ain't a 68000, you know!
Right. I get bus error for such misaligned int access.

Thanks Bernard Leak for the information.

Regards,
Kannan

-----------------------------------------------------------------

From: Bernard Leak [mailto:bernard@brenda-arkle.me.uk] 
Sent: Tuesday, March 05, 2013 2:31 AM
To: gcc-help@gcc.gnu.org
Cc: Mailaripillai, Kannan Jeganathan
Subject: Re: no warning even with -Wcast-align in windows/hp-ux

gcc-help.52314
(apologies if that doesn't thread properly...)
>char char1;
>char char2;
>int *ip;

>void foo(void) {
>  ip = &char1;  // line 6
>  *ip = 65;
>  ip = &char2; // line 8
>  *ip = 66;
>  return;
>}

>No alignment warning at line 6, 8. 
>Tried in windows (GCC 4.5.3), hp-ux (GCC 4.7.1).

Um, why should there be an alignment warning?
Do you *know* that char1, char2 are not both
on appropriately-aligned int boundaries?
Leaving aside the unofficial character of all
Windows builds of GCC (are you using Cygwin
or similar?), misaligned accesses to ints are
not prohibited on. e.g., x86.  It ain't a
68000, you know!

On the other hand, I get a warning "assignment from
incompatible pointer type", for each of the indicated
lines, which is what I'd expect.

                           Bernard Leak.

       reply	other threads:[~2013-03-05  3:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <51350B9A.20602@brenda-arkle.me.uk>
2013-03-05  3:53 ` Mailaripillai, Kannan Jeganathan [this message]
2013-03-05  6:26 ` Mailaripillai, Kannan Jeganathan
2013-03-04 10:23 Mailaripillai, Kannan Jeganathan

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=AA6ADB5A789EDD4DA355F183E8ECDFA675278110@G4W3213.americas.hpqcorp.net \
    --to=kannanmj@hp.com \
    --cc=bernard@brenda-arkle.me.uk \
    --cc=gcc-help@gcc.gnu.org \
    /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).