This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/33295] ICE in fold_const.c (fold_convert) when reordering USE statements
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Sep 2007 19:03:39 -0000
- Subject: [Bug fortran/33295] ICE in fold_const.c (fold_convert) when reordering USE statements
- References: <bug-33295-14773@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from ubizjak at gmail dot com 2007-09-04 19:03 -------
(In reply to comment #3)
> Uros, do you think we could, in the fold_convert() switch on TREE_CODE(type),
> add a case for RECORD_TYPE similar to VECTOR_TYPE: assert that both
> RECORD_TYPEs have the same size, and that their fields correspond one-to-one,
> and then create a VIEW_CONVERT_EXPR? Do you think it would be worth having or
> would that hurt the middle-end in any way?
This is not exactly the part of gcc I'm familiar with (and c never generates
RECORD_TYPEs), but I think that this problem should be fixed in
fortran/trans-expr.c. At least according to the comment above fold_convert(),
this conversion should be handled in front-end convert function.
The "patch" below (similar to your proposal, with minimal checking) "works" in
the sense that the compilation doesn't break, and generated code doesn't create
a black hole at runtime, but I have no idea if it is correct (fortran)
transformation. Also, we will break here if sizes are not equal.
Index: fold-const.c
===================================================================
--- fold-const.c (revision 128092)
+++ fold-const.c (working copy)
@@ -2616,6 +2616,10 @@
|| TREE_CODE (orig) == VECTOR_TYPE);
return fold_build1 (VIEW_CONVERT_EXPR, type, arg);
+ case RECORD_TYPE:
+ gcc_assert (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig)));
+ return fold_build1 (VIEW_CONVERT_EXPR, type, arg);
+
case VOID_TYPE:
tem = fold_ignored_result (arg);
if (TREE_CODE (tem) == GIMPLE_MODIFY_STMT)
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33295