Discussion:
[amd64, regression] pcc fails mksh's built-time assertions
Thorsten Glaser
2012-04-14 14:24:58 UTC
Permalink
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…
--
“Having a smoking section in a restaurant is like having
a peeing section in a swimming pool.”
-- Edward Burr
Anders Magnusson
2012-04-14 16:00:21 UTC
Permalink
It was introduced 6 Jul 2011 20:15:38 when cleaning up some bool stuff.
I cannot tell why, but at least it is fixed now.

-- Ragge
Post by Thorsten Glaser
Hi,
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)); }
x.c:5: warning: integer overflow in expression
= 0
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…
Thorsten Glaser
2012-04-14 16:23:46 UTC
Permalink
It was introduced 6 Jul 2011 20:15:38 when cleaning up some bool stuff. I
cannot tell why, but at least it is fixed now.
Thanks! That was fast.

Just to make sure: from the following definitions, one
must be signed and the other unsigned:

typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));

bye,
//mirabilos
--
If Harry Potter gets a splitting headache in his scar
when he’s near Tom Riddle (aka Voldemort),
does Tom get pain in the arse when Harry is near him?
-- me, wondering why it’s not Jerry Potter………
Anders Magnusson
2012-09-20 19:42:12 UTC
Permalink
Post by Thorsten Glaser
It was introduced 6 Jul 2011 20:15:38 when cleaning up some bool stuff. I
cannot tell why, but at least it is fixed now.
Thanks! That was fast.
Just to make sure: from the following definitions, one
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
That is what it is supposed to be :-)

-- Ragge

Loading...