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: [RFA:] Fix two uninitialized-bugs in cppexp.c spotted by valgrind


On Fri, 29 Nov 2002, Zack Weinberg wrote:
> Hans-Peter Nilsson <hp@bitrange.com> writes:
>
> > 	* cppexp.c (num_part_mul): Initialize result.unsignedp, to 1.
> > 	(eval_token): Initialize temp.

> Please address this by making _cpp_test_assertion always store a value
> into its second argument, instead.  A patch to do that is pre-approved.

Thanks for the review.  This is what I checked in wrt. your request.
Bootstrapped and checked i686-pc-linux-gnu.

	* cpplib.c (_cpp_test_assertion): Default *value to 0.

Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.325
diff -p -c -r1.325 cpplib.c
*** cpplib.c	18 Nov 2002 20:43:35 -0000	1.325
--- cpplib.c	29 Nov 2002 22:37:21 -0000
*************** find_answer (node, candidate)
*** 1689,1695 ****

  /* Test an assertion within a preprocessor conditional.  Returns
     nonzero on failure, zero on success.  On success, the result of
!    the test is written into VALUE.  */
  int
  _cpp_test_assertion (pfile, value)
       cpp_reader *pfile;
--- 1689,1695 ----

  /* Test an assertion within a preprocessor conditional.  Returns
     nonzero on failure, zero on success.  On success, the result of
!    the test is written into VALUE, otherwise the value 0.  */
  int
  _cpp_test_assertion (pfile, value)
       cpp_reader *pfile;
*************** _cpp_test_assertion (pfile, value)
*** 1699,1704 ****
--- 1699,1709 ----
    cpp_hashnode *node;

    node = parse_assertion (pfile, &answer, T_IF);
+
+   /* For recovery, an erroneous assertion expression is handled as a
+      failing assertion.  */
+   *value = 0;
+
    if (node)
      *value = (node->type == NT_ASSERTION &&
  	      (answer == 0 || *find_answer (node, answer) != 0));

brgds, H-P


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