* [PATCH] Fix PR82765
@ 2017-10-30 14:55 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2017-10-30 14:55 UTC (permalink / raw)
To: gcc-patches
The following fixes an ICE in constant pool hashtable functions
for overly large (__int128) array indices. The function doesn't
try to be correct in any way so simply truncate to HWI.
Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?
Thanks,
Richard.
2017-10-30 Richard Biener <rguenther@suse.de>
PR middle-end/82765
* varasm.c (decode_addr_const): Make offset HOST_WIDE_INT.
Truncate ARRAY_REF index and element size.
* gcc.dg/pr82765.c: New testcase.
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 254211)
+++ gcc/varasm.c (working copy)
@@ -2879,7 +2879,7 @@ static void
decode_addr_const (tree exp, struct addr_const *value)
{
tree target = TREE_OPERAND (exp, 0);
- int offset = 0;
+ HOST_WIDE_INT offset = 0;
rtx x;
while (1)
@@ -2893,8 +2893,9 @@ decode_addr_const (tree exp, struct addr
else if (TREE_CODE (target) == ARRAY_REF
|| TREE_CODE (target) == ARRAY_RANGE_REF)
{
- offset += (tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (target)))
- * tree_to_shwi (TREE_OPERAND (target, 1)));
+ /* Truncate big offset. */
+ offset += (TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (target)))
+ * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)));
target = TREE_OPERAND (target, 0);
}
else if (TREE_CODE (target) == MEM_REF
Index: gcc/testsuite/gcc.dg/pr82765.c
===================================================================
--- gcc/testsuite/gcc.dg/pr82765.c (nonexistent)
+++ gcc/testsuite/gcc.dg/pr82765.c (working copy)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -w" } */
+
+int a[1][1];
+int main() { int *b[] = {a, a[1820408606019012862278468], a, a, a}; }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-10-30 14:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30 14:55 [PATCH] Fix PR82765 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).