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]

Committed: real.c (do_divide): Initialize result with a 0.


Spotted with bootstrap and --enable-checking=valgrind:
./xgcc -B./ -B/usr/local/i686-pc-linux-gnu/bin/ \
 -isystem /usr/local/i686-pc-linux-gnu/include \
 -isystem /usr/local/i686-pc-linux-gnu/sys-include \
 -L/home/hp/cvs_areas/combined/ovg/gcc/../ld -O2 \
 -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes \
 -Wmissing-prototypes -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT \
 -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I \
 -I/home/hp/cvs_areas/combined/combined/gcc \
 -I/home/hp/cvs_areas/combined/combined/gcc/ \
 -I/home/hp/cvs_areas/combined/combined/gcc/../include \
 -DL_fixunsdfdi -c /home/hp/cvs_areas/combined/combined/gcc/libgcc2.c \
 -o libgcc/./_fixunsdfdi.o
==16097== Conditional jump or move depends on uninitialised value(s)
==16097==    at 0x80D85B6: exp_equiv_p (cse.c:2637)
==16097==    by 0x80D5BAD: lookup (cse.c:1420)
==16097==    by 0x80DD130: cse_insn (cse.c:4945)
==16097==    by 0x80E21FE: cse_basic_block (cse.c:7174)
==16097==
==16097== Conditional jump or move depends on uninitialised value(s)
==16097==    at 0x80D85B6: exp_equiv_p (cse.c:2637)
==16097==    by 0x80D5BAD: lookup (cse.c:1420)
==16097==    by 0x80DD689: cse_insn (cse.c:5093)
==16097==    by 0x80E21FE: cse_basic_block (cse.c:7174)

In cse.c 1.275 line 2636 we find:
	case 'w':
	  if (XWINT (x, i) != XWINT (y, i))

The code compares the REAL_VALUE_TYPEs of two CONST_DOUBLE rtxes
piecewise.  Somewhat questionable, but still, the members of a
REAL_VALUE_TYPE struct are "packed", with no padding on common
architectures.

Once the introcuction of the X was located, the situation and
solution was obvious: do_divide didn't initialize all the
REAL_VALUE_TYPE fields.  BTW, do_multiply initializes its result
similarly as in this patch.  (Actually it initializes the result
like this, and a temp with memset elsewhere.)

Bootstrapped and checked of combined gcc+src on
i686-pc-linux-gnu (no valgrind) with no regressions (including
whatever pieces of Ada that are exercised by "make bootstrap &&
make check").

A make bootstrap && make check with --enable-checking=valgrind
(languages as above) has made it into stage two without further
valgrind indications and is now compiling c-decl.c.

Committed as obvious.

	* real.c (do_divide): Initialize result with a 0.

Index: real.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.129
diff -c -p -r1.129 real.c
*** real.c	13 Oct 2003 21:16:18 -0000	1.129
--- real.c	29 Oct 2003 21:30:41 -0000
*************** do_divide (REAL_VALUE_TYPE *r, const REA
*** 858,863 ****
--- 858,865 ----
    else
      rr = r;
  
+   /* Make sure all fields in the result are initialized.  */
+   get_zero (rr, 0);
    rr->class = rvc_normal;
    rr->sign = sign;
  
brgds, H-P


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