From owner-freebsd-current Sat Apr 8 13:22:44 2000 Delivered-To: freebsd-current@freebsd.org Received: from rccr1.rccr.cremona.it (rccr1.rccr.cremona.it [194.20.53.49]) by hub.freebsd.org (Postfix) with ESMTP id 7B02337B726; Sat, 8 Apr 2000 13:22:38 -0700 (PDT) (envelope-from mirko.viviani@rccr.cremona.it) Received: from mailman.endymion.com (rccr1.rccr.cremona.it [194.20.53.49] (may be forged)) by rccr1.rccr.cremona.it (8.9.3/8.9.3) with SMTP id WAA05269; Sat, 8 Apr 2000 22:17:21 +0200 Message-Id: <200004082017.WAA05269@rccr1.rccr.cremona.it> To: current@FreeBSD.org Cc: obrien@FreeBSD.org From: mirko.viviani@rccr.cremona.it Subject: 4.0 possible compiler bug ? Date: Sat, 8 Apr 2000 22:17:21 +0000 X-Mailer: Endymion MailMan Standard Edition v3.0.2 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Ciao! I'm testing the __builtin_apply() to make a patch to GNUstep, but I'm getting in troubles. rey:/tmp/tmp> gcc -v Using builtin specs. gcc version 2.95.2 19991024 (release) rey:/tmp/tmp> uname -a FreeBSD rey.procom2.it 4.0-STABLE FreeBSD 4.0-STABLE #0: Fri Apr 7 01:02:03 CEST 2000 mirko@rey.procom2.it:/mnt/amy/lpub/freebsd/usr/obj/mnt/amy/lpub/freebsd/usr/src/sys/rey i386 rey:/tmp/tmp> gcc -o test contest_i.c -Wall contest_i.c: In function `main': contest_i.c:37: warning: implicit declaration of function `printf' rey:/tmp/tmp> ./test Segmentation fault (core dumped) If the sizeof struct p is up to 8 bytes it returns the struct on the stack, else it cores. But it dumps only with the __builtin_apply(), if you define 'pippo' it works. Tested also on 3.4-stable with system gcc and it dumps. I hope I'm wrong, since I need it. Any hints ? <-*- cut -*-> #include struct p { char p[10]; }; struct p p; struct p *value = &p; struct p floatValue() { p.p[0] = 0x20; p.p[1] = 3; p.p[2] = 4; p.p[3] = 0x21; p.p[9] = 0xfe; return p; } int main() { int i; char *(imp) = (char *)floatValue; void* retframe; void* frame = __builtin_apply_args(); //malloc(116); *(void**)frame = 0; #ifdef pippo retframe=frame; floatValue(); #else retframe = __builtin_apply((void(*)(void))imp, frame, 0); #endif for(i=0; i < 40; i++) printf("%02x ", ((unsigned char *)retframe)[i]); printf("\n"); for(i=0; i < 4; i++) printf("%02x ", ((unsigned char *)&value)[i]); printf("\n"); exit(0); } <-*- cut -*-> -- Bye, Mirko To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message