This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66211] [5/6 Regression] Rvalue conversion in ternary operator causes internal compiler error
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 May 2015 08:19:47 +0000
- Subject: [Bug c++/66211] [5/6 Regression] Rvalue conversion in ternary operator causes internal compiler error
- Auto-submitted: auto-generated
- References: <bug-66211-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66211
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we fold (and did fold before) 1 > 0 ? x : y to (float) x (thus an rvalue).
Then later we call ocp_convert on that requesting a conversion to int which
does
810 converted = fold_if_not_in_template (convert_to_integer (type,
e));
where convert_to_integer ends up just doing
910 return build1 (FIX_TRUNC_EXPR, type, expr);
and fold then applying the simplification
/* If we are converting an integer to a floating-point that can
represent it exactly and back to an integer, we can skip the
floating-point conversion. */
(if (inside_int && inter_float && final_int &&
(unsigned) significand_size (TYPE_MODE (inter_type))
>= inside_prec - !inside_unsignedp)
(convert @0))))))
and
(for cvt (convert view_convert float fix_trunc)
(simplify
(cvt @0)
(if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@0)))
|| (GENERIC && type == TREE_TYPE (@0)))
@0)))
where wrapping the result as (non_lvalue @0) fixes the regression. The bug
is of course the C++ frontend folding stuff too early (and too aggressive)
here.
But for GCC 5 the above might be a good-enough workaround (eventually
we can conditionalize building non_lvalue exprs to non-C-frontends).