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

Re: RFH: compile-time assertions now broken in GCC



On 03.10.2012 15:59, Thorsten Glaser wrote:
> Hi,
> 
> https://bugs.launchpad.net/ubuntu/+source/mksh/+bug/1058035
> was just the beginning, as gcc-snapshot in Debian had it (I
> wrote that in the bugreport already), but, now, gcc-4.{6,7}
> in sid also have it.
> 
> I’ve just tracked it down for gcc-4.6 to have been introdu‐
> ced between 4.6.3-9 and 4.6.3-10; gcc-4.7 as currently sits
> in wheezy (4.7.1-7) doesn’t have the problem, 4.7.2-2 does.
> 
> tg@zigo:~/b $ cat t.c
> #include <stdint.h>
> typedef int32_t mksh_ari_t;
> char ari_sign_32_bit_and_wrap[(
> 
>         (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 1) >
>         (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 2)
> 
>     ) ? 1 : -1];
> 
> int main(void) { return (sizeof(ari_sign_32_bit_and_wrap)); }
> tg@zigo:~/b $ gcc-4.6 -O -Wextra t.c
> t.c:6:62: warning: integer overflow in expression [-Woverflow]
> t.c:3:6: error: variably modified ‘ari_sign_32_bit_and_wrap’ at file scope
> 
> My question now is, how am I supposed to deal with that? Will
> the affected gcc versions transition into wheezy? In that case
> I’ll need to apply the hotfix I made for Ubuntu into Debian as
> well, so I’d like an answer.
> 
> More generally, why does GCC suddenly break such compile-time
> check constructs? (mksh guarantees to scripts it runs that all
> arithmetic operations are 32-bit and that both signed and un‐
> signed operations wrap around, so it *must* know whether the
> system does that correctly. And its build script is cross-com‐
> pile agnostic, so it doesn’t do run-time checks.)

how does gcc-snapshot behave? If you think it's a regression, please could you
forward it upstream?

thanks, Matthias


Reply to: