[patch] Add assert to cp/typeck.c (build_x_binary_op)

Alexey Starovoytov Alexey.Starovoytov@Sun.COM
Fri Apr 21 04:08:00 GMT 2006


Hi,

there is a place in cp/pt.c that calls build_x_binary_op (ARRAY_REF,...
I couldn't find a convincing confirmation in the sources that it only
happens when processing_template_decl is zero, because if it's not,
array_ref will be initialized with junk in op2, op3 which will cause
an ICE during pch generation.
So I propose to add the following assert to build_x_binary_op()
just to make sure that we're passing correct number of args.

Tested on sparc-sun-solaris2.9, 2.10

Alex.

         * cp/typeck.c (build_x_binary_op): Add assert
         to make sure that tree_code for build_*() matches
         number of passed args

*** cp/typeck.c Tue Mar 14 09:36:29 2006
--- cp/typeck.c.new     Thu Apr 20 20:39:08 2006
*************** build_x_binary_op (enum tree_code code, 
*** 2811,2816 ****
--- 2811,2817 ----

     if (processing_template_decl)
       {
+       gcc_assert (TREE_CODE_LENGTH (code) == 2);
         if (type_dependent_expression_p (arg1)
           || type_dependent_expression_p (arg2))
         return build_min_nt (code, arg1, arg2);



More information about the Gcc-patches mailing list