This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] testsuite: 16-bit int overflow fixes
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Aug 2007 17:26:04 +0200
- Subject: [PATCH] testsuite: 16-bit int overflow fixes
:ADDPATCH testsuite:
2007-08-28 Rask Ingemann Lambertsen <rask@sygehus.dk>
* gcc.dg/tls/opt-5.c (__gen_tempname): Avoid overflowing 16-bit int.
* gcc.dg/attr-alloc_size.c (test): Likewise.
Index: gcc/testsuite/gcc.dg/tls/opt-5.c
===================================================================
--- gcc/testsuite/gcc.dg/tls/opt-5.c (revision 127806)
+++ gcc/testsuite/gcc.dg/tls/opt-5.c (working copy)
@@ -34,12 +34,12 @@
char *XXXXXX;
static uint64_t value;
uint64_t random_time_bits;
- unsigned int count;
+ unsigned long count;
int fd = -1;
int save_errno = __libc_errno;
struct stat64 st;
- unsigned int attempts_min = 62 * 62 * 62;
- unsigned int attempts = attempts_min < 238328 ? 238328 : attempts_min;
+ unsigned long attempts_min = 62L * 62L * 62L;
+ unsigned long attempts = attempts_min < 238328 ? 238328 : attempts_min;
len = strlen (tmpl);
if (len < 6 || strcmp(&tmpl[len - 6], "XXXXXX"))
Index: gcc/testsuite/gcc.dg/attr-alloc_size.c
===================================================================
--- gcc/testsuite/gcc.dg/attr-alloc_size.c (revision 127806)
+++ gcc/testsuite/gcc.dg/attr-alloc_size.c (working copy)
@@ -23,13 +23,13 @@
p = malloc1 (6);
strcpy (p, "Hello");
strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
- p = malloc2 (424242, 6);
+ p = malloc2 (__INT_MAX__ >= 1700000 ? 424242 : __INT_MAX__ / 4, 6);
strcpy (p, "World");
strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
p = calloc1 (2, 5);
strcpy (p, "World");
strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
- p = calloc2 (2, 424242, 5);
+ p = calloc2 (2, __INT_MAX__ >= 1700000 ? 424242 : __INT_MAX__ / 4, 5);
strcpy (p, "World");
strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
}
--
Rask Ingemann Lambertsen