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.
case ARRAY_TYPE:
HOST_WIDE_INT nelts, fldsz;
fldsz = int_size_in_bytes (TREE_TYPE (type));
+ if (fldsz == 0)
+ break;
nelts = sz / fldsz;
if (nelts > 1
&& sz > 8 * UNITS_PER_WORD
--- /dev/null
+/* PR c/98087 */
+
+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);
+}