Thorsten Glaser
2012-04-14 14:24:58 UTC
Hi,
this used to work:
(pbuild21152)***@builds:~/mksh # cat x.c
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef int32_t mksh_ari_t;
struct ctasserts {
char ari_is_signed[((mksh_ari_t)-1 < (mksh_ari_t)0) ? 1 : -1];
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(struct ctasserts)); }
(pbuild21152)***@builds:~/mksh # gcc x.c; echo = $?
x.c:5: warning: integer overflow in expression
= 0
(pbuild21152)***@builds:~/mksh # pcc x.c; echo = $?
x.c, line 4: array size cannot be negative
x.c, line 5: array size cannot be negative
= 1
The int32_t definition is straight from eglibc (this is a
Debian squeeze/amd64 chroot), the rest is mksh’s assertion
check code.
Why is mksh_ari_t suddenly unsigned, or appears so?
bye,
//mirabilos
PS: Credits for this find go to RT, who is porting mksh to
an amazing number of platforms and compilers…
this used to work:
(pbuild21152)***@builds:~/mksh # cat x.c
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef int32_t mksh_ari_t;
struct ctasserts {
char ari_is_signed[((mksh_ari_t)-1 < (mksh_ari_t)0) ? 1 : -1];
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(struct ctasserts)); }
(pbuild21152)***@builds:~/mksh # gcc x.c; echo = $?
x.c:5: warning: integer overflow in expression
= 0
(pbuild21152)***@builds:~/mksh # pcc x.c; echo = $?
x.c, line 4: array size cannot be negative
x.c, line 5: array size cannot be negative
= 1
The int32_t definition is straight from eglibc (this is a
Debian squeeze/amd64 chroot), the rest is mksh’s assertion
check code.
Why is mksh_ari_t suddenly unsigned, or appears so?
bye,
//mirabilos
PS: Credits for this find go to RT, who is porting mksh to
an amazing number of platforms and compilers…
--
“Having a smoking section in a restaurant is like having
a peeing section in a swimming pool.”
-- Edward Burr
“Having a smoking section in a restaurant is like having
a peeing section in a swimming pool.”
-- Edward Burr