Re: bytegroesse, was endianess/Re: audio-cd

From: Oliver Fromme <olli(at)secnetix.de>
Date: Sat, 23 Mar 2002 00:17:02 +0100 (CET)

Christian Weisgerber <naddy(at)mips.inka.de> wrote:
> Oliver Fromme <de-bsd-questions(at)DE.FreeBSD.ORG> wrote:
> > und starte mal folgendes C-Programm auf 'ner Alpha:
> >
> > int main() {
> > char c; int *p;
> > p = (int *) &c + 1;
> > return *p;
> > }
> >
> > Das fliegt Dir um die Ohren,
>
> Nein.

Sorry, Du hast recht, da ist mir einfach ein Klammernpaar
abhanden gekommen ... Jetzt aber:

$ uname -m
alpha
$ sysctl -a | grep unaligned
machdep.unaligned_print: 1
machdep.unaligned_fix: 0
machdep.unaligned_sigbus: 1
$ cat foo.c
int main() {
        char c; int *p;
        p = (int *) (&c + 1);
        return *p;
}
$ cc -Wall -ansi -pedantic -g -o foo foo.c
$ ./foo
pid 1642 (foo): unaligned access: va=0x11ffb471 pc=0x1200007a0 ra=0x120000698 op=ldl
zsh: 1642 bus error (core dumped) ./foo
$ gdb foo foo.core
[...]
Program terminated with signal 10, Bus error.
#0 0x1200007a0 in main () at foo.c:4
4 return *p;

Gruß
   Olli

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
"All that we see or seem is just a dream within a dream" (E. A. Poe)
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Sat 23 Mar 2002 - 00:17:05 CET

search this site