On Wed, 19 Apr 2006, Daniel Berlin wrote:
make_node does memset, but the loop above is after the call to make_node.
I guess we didn't hit the problem just because tsubst_copy_and_build()
(where build_x_binary_op (ARRAY_REF is) is never called for array_ref when
processing_template_decl is non zero.
Probably.
Unfortunately, TREE_OPERAND checks the static lookup table for how many
operands the tree code is supposed to have, *not* how many operands were
actually allocated to the thing.
... and only if ENABLE_TREE_CHECKING enabled (which by default is off, imho)
There is no way in C to tell the number of args to vararg function.
So build_* stuff is doing its best already.
I guess that sort of assertions need at least a comment or gcc_assert().
My suggestion would be to simply add some gcc_asserts that we don't ever get
ARRAY_REF there :)
That's exactly my point. If such bad init happens, it will be
difficult to spot (unless you doing pch).
How about:
*** cp/typeck.c Wed Mar 8 18:55:49 2006
--- cp/typeck.c.new Wed Apr 19 23:28:15 2006
*************** build_x_binary_op (enum tree_code code,
*** 2697,2702 ****
--- 2697,2703 ----
if (processing_template_decl)
{
+ gcc_assert (TREE_CODE_CLASS (code) == tcc_binary);
if (type_dependent_expression_p (arg1)
|| type_dependent_expression_p (arg2))
return build_min_nt (code, arg1, arg2);