Subject: Re: codegen bug, more info...
To: der Maus <mouse@Rodents.Montreal.Qc.CA>
From: Greywolf <>
List: port-sparc
Date: 10/03/1999 10:07:40
/* <!-- comment here for ease of compilation once the headers are deleted
 * -->
Wow, I know this is two months old; if this has already been
addressed, I apologise (and I'll go and recompile my toolchain).

Mr. Mouse wanted to know if anyone else was experiencing anything
similar to a segv on that code.  I got a bus error, but I suspect
that's differences between 1.4 and 1.4.1, for some reason: */

>From mouse@Rodents.Montreal.QC.CA Mon Aug  9 18:04:48 1999
Date: Sun, 8 Aug 1999 20:17:15 -0400 (EDT)
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Subject: codegen bug, more info

A little while ago, I mentioned a possible codegen bug in egcs on the
sparc (different from all other sparc codegen bugs I am aware of).

I now have a bit more info.  In particular, I have a small test case.

Given egcs-bug.c as enclosed below, when this is built with the pre-1.4
userland, it works; with the 1.4 userland, it cores (all work done on
the same hardware under the same, 1.4 vintage, kernel).  Specifically,

% ./egcs-bug		# built with pre-1.4 userland ("")
wrap(0) -> 1
wrap(1) -> 0
% /mnt/egcs-bug		# built with 1.4 userland (ie, egcs)
wrap(0) -> 1
Segmentation fault (core dumped)

I'd appreciate it if someone else could try this.  While similar
conditions (identical hardware and kernel, differing userland) would of
course be preferable, I'd be interested in results from anyone.  I'd be
especially interested to hear if this is for real in 1.4 but has been
fixed in something later.

Here's egcs-bug.c, up to my signature.
#include <stdio.h>

static void (*failfn)(void);

#define FAIL ((*failfn)())

static int wrap(void (*fn)(unsigned char), unsigned char arg)
 __label__ fail;

 static void _fail(void)
  { goto fail;

 if (0)
 failfn = &_fail;

static void testfn(unsigned char x)
 if (x != 0) FAIL;

int main(void);
int main(void)
 int v;

 v = wrap(testfn,0);
 printf("wrap(0) -> %d\n",v);
 v = wrap(testfn,1);
 printf("wrap(1) -> %d\n",v);

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

NetBSD: Resistance is NOT futile!