This is the mail archive of the
mailing list for the GCC project.
RFA: fix valgrind failures 1/3
- From: Joern RENNECKE <joern dot rennecke at st dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 25 Jan 2005 19:39:25 +0000
- Subject: RFA: fix valgrind failures 1/3
Running a some commercial testsuite code under valgrind found three
problems with uninitialized data. Two of then in real.c which later
turned up cse.c:exp_equiv_p in this code:
if (XWINT (x, i) != XWINT (y, i))
because some fields in the struct real_value had not been initialized.
The third was a g++ parser error that showed close to the source of the
The problems were found in a gcc 3.4.3 based compiler, but the patches
could be applied to 4.0 mainline with little editing, and source code
inspection shows that they are still relevant.
I've regression tested these patches in a mainline snapshot from yesterday
on i686-pc-linux-gnu X sh-elf, and bootstrapped / compared / regtested
on i686-pc-linux-gnu native without new regressions.
Today I post the 4.0 mainline versions of these patches, as regtested.
We can address the 3.4 patches later.
The first patch is to do_add; the problem was triggered from constant
folding of an addition. Since do_add might be called with the result
pointer aliasing one or both inputs, and the rvc_normal/rvc_normal code
has the result already partially live before the inputs are die,
initialization of the entire struct with memcpy is not suitable.
Therefore, we have to initialize individual structure fields.
2005-01-21 J"orn Rennecke <firstname.lastname@example.org>
* real.c (do_add): Initialize signalling and canonical members.
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.150
diff -p -r1.150 real.c
*** real.c 21 Jan 2005 17:54:23 -0000 1.150
--- real.c 25 Jan 2005 18:45:17 -0000
*************** do_add (REAL_VALUE_TYPE *r, const REAL_V
*** 640,645 ****
--- 640,648 ----
r->cl = rvc_normal;
r->sign = sign;
SET_REAL_EXP (r, exp);
+ /* Zero out the remaining fields. */
+ r->signalling = 0;
+ r->canonical = 0;
/* Re-normalize the result. */