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

--- Comment #5 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Sorry, this still seems over-reduced: the 'cmp' variable is uninitialized, and
gcc-7 completely optimizes out the block with large stack usage guarded by 'cmp
== 0' test, so gcc-7 vs gcc-8 is not directly comparable. It's strange that
gcc-7 optimizes that out, but it's a different issue.

Can you attach the unreduced preprocessed source, and if you make another
attempt at reducing, perhaps enable most warnings?

That said, it seems gcc is not very good at re-discovering non-overlapping
stack allocations introduced by inlining. Looking at your testcase I came up
with the following minimal test:

struct S{~S();};

void f(void *);

inline void ff()
{
  char c[1000];
  f(c);
}

void g(int n)
{
  S s;
  char c[100];
  f(c);
  if (n) ff(), ff();
}

(there's no regression vs. gcc-7 on this example, but gcc-4.6 used to get a
better result by consuming 1100 bytes rather than 2100).

Reply via email to