This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/83415] ICE during gimplification of assignment to read-only vector


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2017-12-14
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed on x86_64 with

const short __attribute__((vector_size(16))) y = { 0, 1, 2, 3, 4, 5, 6, 7 };

int
main (int argc, short *argv[])
{
  int i = argc;
  y[i] = 7 - i;
  return 0;
}

Here the FE already folds the constant initializer with optimization:

  VIEW_CONVERT_EXPR<short int[8]>({ 0, 1, 2, 3, 4, 5, 6, 7 })[i] = (short int)
(7 - (unsigned short) i);

but not so without:

  VIEW_CONVERT_EXPR<short int[8]>(y)[i] = (short int) (7 - (unsigned short) i);

Either the program should be rejected or the FE should avoid folding an
lvalue to an rvalue.

Index: gcc/c/c-fold.c
===================================================================
--- gcc/c/c-fold.c      (revision 255622)
+++ gcc/c/c-fold.c      (working copy)
@@ -434,6 +434,7 @@ c_fully_fold_internal (tree expr, bool i
       goto unary;
     case REALPART_EXPR:
     case IMAGPART_EXPR:
+    case VIEW_CONVERT_EXPR:
       op0_lval = lval;
       /* FALLTHRU */
     case INDIRECT_REF:
@@ -441,7 +442,6 @@ c_fully_fold_internal (tree expr, bool i
     case FLOAT_EXPR:
     CASE_CONVERT:
     case ADDR_SPACE_CONVERT_EXPR:
-    case VIEW_CONVERT_EXPR:
     case NON_LVALUE_EXPR:
     case NEGATE_EXPR:
     case BIT_NOT_EXPR:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]