On Wed, Dec 02, 2020 at 10:25:32AM +0100, Martin Liška wrote: > It's a simple fix of a division by zero. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > gcc/ChangeLog: > > PR c/98087 > * gimple-fold.c (clear_padding_type): Do not divide by zero. > > gcc/testsuite/ChangeLog: > > PR c/98087 > * gcc.c-torture/compile/pr98087.c: New test.
Ok, but can you extend the testcase a little bit to cover more cases? > --- /dev/null > +++ b/gcc/testsuite/gcc.c-torture/compile/pr98087.c > @@ -0,0 +1,8 @@ > +/* PR c/98087 */ > + > +struct S {}; > +void foo (int n) > +{ > + struct S a[n][0]; > + __builtin_clear_padding (a); > +} Like: struct S { char a; long long b; }; struct T { struct S c[0]; char d; }; void foo (int n) { struct S a[n][0]; __builtin_clear_padding (a); __builtin_clear_padding (&a); struct S b[7][0]; __builtin_clear_padding (&b); struct T c; __builtin_clear_padding (&c); } Without your patch we ICE on the first 3, the 4th not because the zero length array satisfies is_empty_type. For the &a case, I even thought I do handle that (the if (eltsz) conditional), but unlike my expectations, int_size_in_bytes of the VLA with zero sized elements is not -1, but 0. Jakub