RFH: compile-time assertions now broken in GCC
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.)
Thanks in advance,
//mirabilos
--
“It is inappropriate to require that a time represented as
seconds since the Epoch precisely represent the number of
seconds between the referenced time and the Epoch.”
-- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2
Reply to: