This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] [9411-001] Fix array size overflow
- To: gcc-patches at gcc dot gnu dot org
- Subject: [Ada] [9411-001] Fix array size overflow
- From: bosch at gnat dot com
- Date: Tue, 30 Oct 2001 16:26:57 -0500 (EST)
Tested and bootstrapped on GNU Linux/x86.
-Geert
2001-10-30 Richard Kenner <kenner@gnat.com>
* utils2.c (build_allocator): Test for SIZE overflow in array case too
*** utils2.c 2001/10/20 18:05:36 1.2
--- utils2.c 2001/10/29 20:25:51 1.3
***************
*** 1855,1860 ****
--- 1855,1865 ----
&& contains_placeholder_p (size))
size = build (WITH_RECORD_EXPR, sizetype, size, init);
+ /* If the size overflows, pass -1 so the allocator will raise
+ storage error. */
+ if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
+ size = ssize_int (-1);
+
storage = build_call_alloc_dealloc (NULL_TREE, size,
TYPE_ALIGN (storage_type),
gnat_proc, gnat_pool);