* bus error in sparc ultra 10 solaris 8 g++ 2.95 3.0
@ 2001-11-09 15:02 agustin
2001-11-10 2:06 ` John Love-Jensen
0 siblings, 1 reply; 2+ messages in thread
From: agustin @ 2001-11-09 15:02 UTC (permalink / raw)
To: 'help-gcc@gnu.org'
unsigned long x;
> char p[15];
> .
> strcpy (p, "abcdefghijkl");
> x = *(unsigned long *)((char *)p + 3); // <<<----------------here bus error
>
> why ??
> this instruction is not standard c ?? and why
> x = *(unsigned long *)((char *)p + 4); // not failure ???
>
> i know that can write
> memcpy ((char *)&x, (char *)(p+3), sizeof(unsigned long));
>
> but what happen ?? error in compiler o ????
> thanks for your help.
> Agustin.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: bus error in sparc ultra 10 solaris 8 g++ 2.95 3.0
2001-11-09 15:02 bus error in sparc ultra 10 solaris 8 g++ 2.95 3.0 agustin
@ 2001-11-10 2:06 ` John Love-Jensen
0 siblings, 0 replies; 2+ messages in thread
From: John Love-Jensen @ 2001-11-10 2:06 UTC (permalink / raw)
To: agustin, help-gcc
You are trying to perform an illegal operation on the Sun architecture.
A char* is not a long*.
The Sun architecture requires that long data is aligned. You are attempting
an unaligned access, which will cause a BUS signal.
Don't cast. Casts are indicative that you may be doing something wrong. In
this instance, you are.
--Eljay
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-11-20 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-09 15:02 bus error in sparc ultra 10 solaris 8 g++ 2.95 3.0 agustin
2001-11-10 2:06 ` John Love-Jensen
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).