* 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 ` 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