diff options
-rw-r--r-- | gcc/gimple-fold.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr98087.c | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 1f3d80e..ab74494 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -4552,6 +4552,8 @@ clear_padding_type (clear_padding_struct *buf, tree type, HOST_WIDE_INT sz) 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 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr98087.c b/gcc/testsuite/gcc.c-torture/compile/pr98087.c new file mode 100644 index 0000000..8cac770 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr98087.c @@ -0,0 +1,14 @@ +/* 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); +} |