[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OpenBSD g++ (propolice) compiler bug?
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Re: OpenBSD g++ (propolice) compiler bug?
- From: Alf Schlichting <a_(_dot_)_schlichting_(_at_)_lemarit_(_dot_)_com>
- Date: Fri, 4 Mar 2005 11:46:20 +0100
- Cc: Daniel Hartmeier <daniel_(_at_)_benzedrine_(_dot_)_cx>
Am Freitag, 4. Mdrz 2005 10:55 schrieb Daniel Hartmeier:
> #include <string.h>
>
> struct S {
> char a[16];
> int b;
> };
>
> int i;
>
> void
> fn()
> {
> {
> }
> {
> char e;
> }
>
> {
> char f[12];
> }
>
> {
> struct S s;
> printf("&s %p\n", &s);
> printf("&s.a %p\n", &s.a);
> printf("&s.b %p\n", &s.b);
> strcpy(s.a, "ABCDEFGHIJKLMNO");
> s.b = 55;
> printf("set s.b = %d\n", s.b);
> memcpy(&i, &s.b, sizeof(int));
> printf("copied back int %d\n", i);
> printf("sizeof(s) %d\n", (int)sizeof(s));
> for (i = 0; i < sizeof(s); ++i)
> printf("%2.2X ", *((unsigned char *)&s + i));
> printf("\n");
> }
> }
>
> int
> main()
> {
> fn();
> return (0);
> }
This is from hppa-maschine:
leopold_(_at_)_hpux:3$ cc -v
Reading specs from /usr/lib/gcc-lib/hppa-unknown-openbsd3.6/3.3.5/specs
Configured with:
Thread model: single
gcc version 3.3.5 (propolice)
leopold_(_at_)_hpux:4$ cc test.c
/tmp//ccPX8030.o(.text+0x6c): In function `fn':
: warning: strcpy() is almost always misused, please use strlcpy()
leopold_(_at_)_hpux:5$ ./a.out
&s 0x780077c0
&s.a 0x780077c0
&s.b 0x780077d0
set s.b = 55
copied back int 55
sizeof(s) 20
41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 00 00 00 00 37
leopold_(_at_)_hpux:6$ uname -a
OpenBSD hpux.rechners.hier 3.6 GENERIC#211 hppa
leopold_(_at_)_hpux:7$ ls -l /bin/ls
-r-xr-xr-x 1 root bin 215184 Dec 29 12:19 /bin/ls*
leopold_(_at_)_hpux:8$
Looks like a -current from late December 2004.
Alf
Visit your host, monkey.org