------- Additional Comments From rguenth at gcc dot gnu dot org  2005-08-30 
09:42 -------
While my patch is to the middle-end, the C++ frontend part causing this is

build_x_conditional_expr
...
  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);

where in the case of a template decl, the valid expr i != 0 ? 0 : i is
thrown away and rebuilt as i ? 0 : i, where the default conversion is no
longer applied.  That could be fixed using perform_implicit_conversion
(boolean_type_node, orig_ifexp) - but I don't know if that would succeed
in case of i being a template param.  We use this (potentially dependent)
expr later to create a non-dependent expr where we fail to apply the
default conversion, too, in

pt.c:build_non_dependent_expr

we could fix that there, too, performing default conversion if the type
is not correct.  And later in

typeck.c:build_array_ref

we happen to call fold on the invalid(?) COND_EXPR.

Of course I'm a lot less confident on the C++ fix than on the fold one.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23624

Reply via email to