[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gcc-6 fails to compile a valid code



control: tags -1 - moreinfo
control: tags -1 - unreproducible


On Mon, 4 Apr 2016 10:22:54 +0000 (UTC) Gianfranco Costamagna
<locutusofborg@debian.org> wrote:
> 
> Hi, the code you posted fails on unstable/experimental with gcc-4.9, gcc-5 and gcc-6

Actually it was me, who posted the code. I've just seen your e-mail
after the issue was re-assigned back to ucl.


> gcc-6 test.c 
> test.c:1:12: error: size of array '__acc_cta' is negative
> extern int __acc_cta[1-2*!((1l << (8*4 -1)) < 0)];

I can still reproduce the issue on i386, but I guess you use amd64. In
such a case you need to replace `4' with `8' (the value `4' was expanded
from sizeof(long) by the macro included at the bottom of my previous
e-mail):

(experimental_amd64-dchroot)robert@barriere:~$ gcc-6 ./test.c
./test.c:1:12: error: variably modified '__acc_cta' at file scope
 extern int __acc_cta[1-2*!((1l << (8*8 -1)) < 0)];
            ^~~~~~~~~
(experimental_amd64-dchroot)robert@barriere:~$ gcc-5 ./test.c
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'

> 
> 
> not sure what is wrong, but seems not a bug in gcc.

I've  found quite similar gcc bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55009

The reasoning given there suggests that you are right, and this is not
gcc bug, as the expression 1l << 63 on amd64 or 1l << 31 on i386
involves undefined behaviour.

I'll try to fix the issue at ucl side by switching to _Static_assert.

Regards,
robert


Reply to: