https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112622

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
          Component|c                           |middle-end
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
   Last reconfirmed|                            |2023-11-20
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  It looks like it's c-typeck.cc:build_c_cast job to reject this
conversion though c_convert also does some checks related to VECTOR_TYPE
(but only as target, not as source).  Even the middle-end convert_to_real_1
does some diagnostics.

Note the ICE is in premature optimization as well.  An easy fix would be

diff --git a/gcc/convert.cc b/gcc/convert.cc
index ac6af7026a7..930b593fc0a 100644
--- a/gcc/convert.cc
+++ b/gcc/convert.cc
@@ -292,7 +292,7 @@ convert_to_real_1 (tree type, tree expr, bool fold_p)
        case NEGATE_EXPR:
          if (!flag_rounding_math
              && FLOAT_TYPE_P (itype)
-             && TYPE_PRECISION (type) < TYPE_PRECISION (itype))
+             && element_precision (type) < element_precision (itype))
            {
              tree arg = convert_to_real_1 (type, TREE_OPERAND (expr, 0),
                                            fold_p);

though the error message is a bit confusing:

t.c:3:1: error: aggregate value used where a floating-point was expected
    3 | V v = (float)-v;
      | ^

Reply via email to