------- Additional Comments From roger at eyesopen dot com 2005-04-23 16:56
-------
Doh, fold_if_not_in_template is not on the gcc 3.4 branch. It was introduced
to fix (workaround?) PR c++/17642, which looks too intrusive for the 3.4 branch.
Instead, the C++ mistake on the 3.4 branch, that's worked around by Mark's
fix for c++/17642 on mainline, is in build_x_conditional_expr in cp/typeck.c.
In this function, g++ calls expr = build_conditional_expr, which it assumes
will always return a tree with TREE_CODE COND_EXPR (after calling fold!). So
when processing_template_decl, it then calls build_min_non_dep with a tree_code
that doesn't match the TREE_CODE of "expr" (which can potentially stomp memory).
More importantly, the orig_op1 and orig_op2 at this point haven't been promoted
to the correct result type, and builting a raw COND_EXPR in build_min_non_dep
with mismatched types later breaks things.
I'm not sure how to fix these lines:
expr = build_conditional_expr (ifexp, op1, op2);
if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (COND_EXPR, expr,
orig_ifexp, orig_op1, orig_op2);
Perhaps something like:
if (TREE_CODE (expr) != COND_EXPR)
expr = build (COND_EXPR, TREE_TYPE (expr),
convert (boolean_type_node, ifexp),
convert (TREE_TYPE (expr), op1),
convert (TREE_TYPE (expr), op2));
where we recover the correct type to promote the operands to from the
type of the result. Once again, orig_op1 = 0.0, orig_op2 = 0, and after
applying standard conversions both become 0.0, so "expr" ends up being
a REAL_CST, 0.0. Perhaps it's possible to do better in the call to
build_min_non_dep.
--
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |driver
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20995