diff mbox

[C++] Use of a variable with undefined value in cp/parser.c?

Message ID 20110606143716.GA14475@virgil.arch.suse.de
State New
Headers show

Commit Message

Martin Jambor June 6, 2011, 2:37 p.m. UTC
Hi,

when testing my new IPA-CP with make profiledbootstrap, I stumbled
across a warning-made-error in parser.c, claiming that parenthesized_p
in cp_parser_parameter_declaration_list is used but undefined.  I do
not understand the code very much but what happens is that the
variable is passed by reference to cp_parser_parameter_declaration and
this is the only call where the function is not passed NULL for that
parameter.  IPA-CP decided to make a specialized version for all the
other calls where the parameter is NULL and therefore this call became
the only one of the original static function and was therefore
inlined.  Somehow the compiler then figured out the variable is never
set but is tested.  Unfortunately something similar elsewhere is
necessary to trigger the warning because it just does not happen if I
do the above manually.

The patch below fixes my problem with profiled bootstrap and is
obviously correct but since if the warning is true there is a
condition in cp_parser_parameter_declaration_list that either is never
true or depends on random input I thought that C++ people might want
to have a look and perhaps remove the parenthesized_p parameter of
cp_parser_parameter_declaration.

All in all, I intend to commit the following in a few days unless
someone stops me.

Thanks,

Martin

2011-06-06  Martin Jambor  <mjambor@suse.cz>

	* parser.c (cp_parser_parameter_declaration_list): Initialize
	parenthesized_p.
diff mbox

Patch

Index: src/gcc/cp/parser.c
===================================================================
--- src.orig/gcc/cp/parser.c
+++ src/gcc/cp/parser.c
@@ -15870,7 +15870,7 @@  cp_parser_parameter_declaration_list (cp
     {
       cp_parameter_declarator *parameter;
       tree decl = error_mark_node;
-      bool parenthesized_p;
+      bool parenthesized_p = false;
       /* Parse the parameter.  */
       parameter
 	= cp_parser_parameter_declaration (parser,