* [PATCH] FIx C/32796, ICE in int_fits_type_p
@ 2007-08-06 13:15 Andrew Pinski
2007-08-08 0:48 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2007-08-06 13:15 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 873 bytes --]
Hi,
The problem here is that pointer_plus_expr merge exposed a latent
bug in the C front-end when it tries to call int_fits_type_p with a
pointer type which causes an ICE. The arguments to build_binary_op at
this point are correct, we have:
(long unsigned int) (ptr + 0xffffffffffffffffffffffffffffffff)
1
We call get_narrower on both of those and we get a pointer type for
the first argument which we then call c_common_signed_or_unsigned_type
and get back a pointer type again and then we try to call
int_fits_type_p but ICEs.
This patch fixes the problem by checking for a pointer type before
calling int_fits_type_p.
OK? Bootstrapped and tested on i386-apple-darwin8.10 with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* c-typeck.c (build_binary_op): Check for non pointer types before
calling int_fits_type_p.
* gcc.c-torture/compile/pr32796.c: New test.
[-- Attachment #2: fixpr32796.diff.txt --]
[-- Type: text/plain, Size: 1312 bytes --]
Index: c-typeck.c
===================================================================
--- c-typeck.c (revision 127240)
+++ c-typeck.c (working copy)
@@ -8225,8 +8225,9 @@ build_binary_op (enum tree_code code, tr
< TYPE_PRECISION (result_type))
&& (type
= c_common_signed_or_unsigned_type (unsigned1,
- TREE_TYPE (arg1)),
- int_fits_type_p (arg0, type)))
+ TREE_TYPE (arg1)))
+ && !POINTER_TYPE_P (type)
+ && int_fits_type_p (arg0, type))
result_type = type;
else if (TREE_CODE (arg1) == INTEGER_CST
&& (unsigned0 || !uns)
@@ -8234,8 +8235,9 @@ build_binary_op (enum tree_code code, tr
< TYPE_PRECISION (result_type))
&& (type
= c_common_signed_or_unsigned_type (unsigned0,
- TREE_TYPE (arg0)),
- int_fits_type_p (arg1, type)))
+ TREE_TYPE (arg0)))
+ && !POINTER_TYPE_P (type)
+ && int_fits_type_p (arg1, type))
result_type = type;
}
Index: testsuite/gcc.c-torture/compile/pr32796.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr32796.c (revision 0)
+++ testsuite/gcc.c-torture/compile/pr32796.c (revision 0)
@@ -0,0 +1,6 @@
+
+
+__SIZE_TYPE__ f (void *ptr)
+{
+ return ((__SIZE_TYPE__)(ptr)-1) | 1ULL;
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] FIx C/32796, ICE in int_fits_type_p
2007-08-06 13:15 [PATCH] FIx C/32796, ICE in int_fits_type_p Andrew Pinski
@ 2007-08-08 0:48 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2007-08-08 0:48 UTC (permalink / raw)
To: Andrew Pinski; +Cc: gcc-patches
"Andrew Pinski" <pinskia@gmail.com> writes:
> * c-typeck.c (build_binary_op): Check for non pointer types before
> calling int_fits_type_p.
This is OK.
Thanks.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-08 0:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06 13:15 [PATCH] FIx C/32796, ICE in int_fits_type_p Andrew Pinski
2007-08-08 0:48 ` Ian Lance Taylor
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).