Patchwork Fix cp_parser_braced_list

login
register
mail settings
Submitter Jakub Jelinek
Date March 4, 2013, 9:22 p.m.
Message ID <20130304212240.GZ12913@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/224839/
State New
Headers show

Comments

Jakub Jelinek - March 4, 2013, 9:22 p.m.
Hi!

As reported by valgrind, cp_parser_braced_list doesn't initialize
*non_constant_p when seeing just {}, and thus when e.g. cp_parser_condition
calls it, non_constant_p is uninitialized when cp_finish_decl
is called with !non_constant_p.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2013-03-04  Jakub Jelinek  <jakub@redhat.com>

	* parser.c (cp_parser_braced_list): For {} initialize
	*non_constant_p to false.


	Jakub
Jason Merrill - March 5, 2013, 2:10 p.m.
OK.

Jason

Patch

--- gcc/cp/parser.c.jj	2013-02-14 09:37:16.000000000 +0100
+++ gcc/cp/parser.c	2013-03-04 19:14:00.629442603 +0100
@@ -17854,6 +17854,8 @@  cp_parser_braced_list (cp_parser* parser
       if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
 	cp_lexer_consume_token (parser->lexer);
     }
+  else
+    *non_constant_p = false;
   /* Now, there should be a trailing `}'.  */
   cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
   TREE_TYPE (initializer) = init_list_type_node;