Hi,
there is a division by zero bug in decl.c:declarator at line 701.
if (e->u.constant.u > ULLONG_MAX / base.type->size)
error(&tok.loc, "array length is too large");
The bug is hidden when you compile with gcc because it replaces the
division even when no optimization is enabled.
To reproduce the bug:
$ make CC=clang
$ ./cproc-qbe test/compatible-vla-types.c
Floating point exception (core dumped)
The target is x86_64-linux-gnu and I cloned cproc from github.
Hope it helps.
Davide Di Paolo <davide.dipaolo09@gmail.com> wrote:
> Hi,
> there is a division by zero bug in decl.c:declarator at line 701.
>
> if (e->u.constant.u > ULLONG_MAX / base.type->size)
> error(&tok.loc, "array length is too large");
>
> The bug is hidden when you compile with gcc because it replaces the
> division even when no optimization is enabled.
>
> To reproduce the bug:
>
> $ make CC=clang
> $ ./cproc-qbe test/compatible-vla-types.c
> Floating point exception (core dumped)
>
> The target is x86_64-linux-gnu and I cloned cproc from github.
>
> Hope it helps.
Hi Davide,
Thanks for reporting this issue. I fixed it in da58ac4dbe.