public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: no warning even with -Wcast-align in windows/hp-ux
       [not found] <51350B9A.20602@brenda-arkle.me.uk>
@ 2013-03-05  3:53 ` Mailaripillai, Kannan Jeganathan
  2013-03-05  6:26 ` Mailaripillai, Kannan Jeganathan
  1 sibling, 0 replies; 3+ messages in thread
From: Mailaripillai, Kannan Jeganathan @ 2013-03-05  3:53 UTC (permalink / raw)
  To: Bernard Leak, gcc-help

> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: no warning even with -Wcast-align in windows/hp-ux
       [not found] <51350B9A.20602@brenda-arkle.me.uk>
  2013-03-05  3:53 ` no warning even with -Wcast-align in windows/hp-ux Mailaripillai, Kannan Jeganathan
@ 2013-03-05  6:26 ` Mailaripillai, Kannan Jeganathan
  1 sibling, 0 replies; 3+ messages in thread
From: Mailaripillai, Kannan Jeganathan @ 2013-03-05  6:26 UTC (permalink / raw)
  To: Bernard Leak, gcc-help

> > It ain't a 68000, you know!
> Right. I get bus error for such misaligned int access.
Correction. I didn't try with 68000. 
I used ia64 hp server rx7640 HP-UX B.11.31.

Regards,
Kannan

-----Original Message-----
From: Mailaripillai, Kannan Jeganathan 
Sent: Tuesday, March 05, 2013 9:22 AM
To: 'Bernard Leak'; gcc-help@gcc.gnu.org
Subject: RE: no warning even with -Wcast-align in windows/hp-ux

> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* no warning even with -Wcast-align in windows/hp-ux
@ 2013-03-04 10:23 Mailaripillai, Kannan Jeganathan
  0 siblings, 0 replies; 3+ messages in thread
From: Mailaripillai, Kannan Jeganathan @ 2013-03-04 10:23 UTC (permalink / raw)
  To: gcc-help

Hi,

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).

Regards,
Kannan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-05  6:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <51350B9A.20602@brenda-arkle.me.uk>
2013-03-05  3:53 ` no warning even with -Wcast-align in windows/hp-ux Mailaripillai, Kannan Jeganathan
2013-03-05  6:26 ` Mailaripillai, Kannan Jeganathan
2013-03-04 10:23 Mailaripillai, Kannan Jeganathan

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).