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/59711] ICE in force_constant_size, at gimplify.c:619 with variably-modified return type


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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
int f(int n)
{
  struct S {
    int a[n];
  };

  struct S g(void) 
  {
    struct S s;
    s.a[0] = 0;
    return s;
  }
  return g ().a[0];
}

I believe this isn't fixable with the GIMPLE IL as-is - without lowering
to the fact that g () returns by storing to a return slot.  Not sure why
3.4 ICEd (2.95.2 also ICEs btw ...).

Well, maybe we can fix it if we allow creating of a variable-size temporary
during gimplification.  That is, the gimple code needs to look like

  tem = WITH_SIZE_EXPR <g (), sizeof (S)>;
  return tem.a[0];

which of course then has the issue that we can't have WITH_SIZE_EXPR around
calls.  Thus really the only way is to lower the return slot fact early.

  g (&tem);
  return tem.a[0];

Eventually not that way but using a special slot on the call stmt similar
to the chain / fn pointer.  Enlarges all call stmts, of course.


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