This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bootstrap failure on solaris2.7 (was: new real.c implementation)


 > From: Richard Henderson <rth@redhat.com>
 > 
 > I can reproduce this, but I don't seem to be able to debug it.  We
 > don't seem to have dbx installed, and gdb won't read cc's debug
 > information.
 > 
 > >   [4] real_digit(n = -1), line 1964 in "real.c"
 > 
 > This should never happen.  N should be between 0 and 9.
 > Can you find out why this happened?
 > r~

I'm still getting the solaris2 bootstrap failure when using cc for
stage1 but I made some more progress in narrowing down why.

I figured out what functions were affected by the different stage1
compiler here http://gcc.gnu.org/ml/gcc-patches/2002-09/msg01286.html
So I set breakpoints in the three functions and ran dbx on
cc1-built-by-cc and gdb on cc1-built-by-gcc-2.95.2 side by side until
I found the line where they produced different computational results.
It took a while but I finally got it.

(The source input was a file containing "extern int i;".)

The difference occurs with today's CVS real.c:540 in this code:

 > 540               r->exp = exp;

In this case, `exp' contains -1 and r is the parameter to the
containing function, normalize().  Its type is REAL_VALUE_TYPE*

After the assignment in cc1-built-by-cc, r contains:

 > (/opt/SUNWspro/bin/../WS5.0/bin/sparcv9/dbx) print *r
 > *r = { class = rvc_normal sign = 0 exp = 536870911 sig = (2765296790U,
 >     3485820830U, 2347382017U, 432528403U) }

whereas in cc1-built-by-gcc, r contains:

 > (gdb) print *r
 > $33 = {class = rvc_normal, sign = 0, exp = -1, sig = {2765296790,
 > 3485820830, 2347382017, 432528403}}

Notice the value of r->exp is 536870911 vs -1.

I've written a simple testcase which reproduces the error.  If you
compile the following with solaris2 cc you'll get:

 > 536870911 3777777777 1fffffff

whereas with gcc you'll get:

 > -1 37777777777 ffffffff

I don't know if this is because of a bug in solaris2 cc or something
else like an ambiguity in what the standard says about bitfields
behavior or whatever.  I'm using:

 > cc: WorkShop Compilers 5.0 98/12/15 C 5.0

Anyway, I think I've taken it as far as I can.  Let me know if I can
help further, but I suspect I'll have to leave the exact diagnosis and
cure up to you.

		Thanks,
		--Kaveh

------------------cut here-------------------------------
enum real_value_class {
  rvc_zero,
  rvc_normal,
  rvc_inf,
  rvc_nan
};

#define HOST_BITS_PER_LONG	(sizeof(long)*8)
#define SIGNIFICAND_BITS	128
#define EXP_BITS		(32 - 3)
#define SIGSZ			(SIGNIFICAND_BITS / HOST_BITS_PER_LONG)

struct real_value
{
  enum real_value_class class : 2;
  unsigned int sign : 1;
  int exp : EXP_BITS;
  unsigned long sig[SIGSZ];
};

int main()
{
  struct real_value r;
  r.exp = -1;
  printf ("%d %o %x\n", r.exp, r.exp, r.exp);
  return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]