C compiler bug on SGIs, maybe MIPS in general ...
Cameron Simpson
cameron at vast.eecs.unsw.oz.au
Mon Nov 26 20:43:33 AEST 1990
Here's a bug in the C compiler on an IRIX 3.3.1 machine. It may
apply to all MIPS machines.
Consider the following (reduced from code using <sys/wait.h> etc):
#define WTERMSIG(x) (((union u *)&(x))->z)
union u { short z;
};
int
v(x)
int x;
{
return (x != 0)|WTERMSIG(x);
}
When compiled it causes the C compiler to say
ugen: internal : line 10 : translate.p, line 1828
offset/length mismatch between vreg and reference
Line 10 is the return statement.
If I change the `short' in the union definition `int' everything is fine.
If I remove the `(x != 0)|' from the return expression everything is fine.
My current workaround is to declare a static function, so:
#ifdef sgi /* may be generic MIPS, but don't know yet */
static int
wtermsig(x)
int x;
{
return WTERMSIG(x);
}
#else
# define wtermsig(x) WTERMSIG(x)
#endif
and then to return
return (x != 0)|wtermsig(x);
cc -V says:
cc (cc)
Mips Computer Systems 2.0
/usr/lib/cpp:
/usr/lib/ujoin:
/usr/bin/uld:
/usr/lib/usplit:
/usr/lib/umerge:
/usr/lib/uopt:
/usr/lib/ugen:
/usr/lib/as0:
/usr/lib/as1:
/usr/bin/ld:
/usr/lib/ftoc:
/usr/lib/cord:
ldclose.c: 1.3 2/16/83
ldopen.c: 1.3 2/16/83
ldohseek.c: 1.1 1/7/82
ldshread.c: 1.1 1/7/82
ldsseek.c: 1.1 1/7/82
ldnsseek.c: 1.1 1/7/82
ldgetname.c: 1.2 2/16/83
ldgetname.c: 1.2 2/16/83
ldtbread.c: 1.1 1/7/82
ldrseek.c: 1.1 1/7/82
ldnrseek.c: 1.1 1/7/82
vldldptr.c: 1.1 1/8/82
allocldptr.c: 1.2 2/16/83
freeldptr.c: 1.1 1/7/82
ldnshread.c: 1.1 1/7/82
/usr/lib/crt1.o:
/usr/lib/crtn.o:
Has anyone else seen this? Is there a version of the compiler with a fix?
- Cameron Simpson
cameron at spectrum.cs.unsw.oz.au
More information about the Comp.sys.sgi
mailing list