This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/32813] [4.3 Regression] ICE for array expression in empty if statement, compiled with -fbounds-check
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jul 2007 07:28:15 -0000
- Subject: [Bug middle-end/32813] [4.3 Regression] ICE for array expression in empty if statement, compiled with -fbounds-check
- References: <bug-32813-14773@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from pinskia at gcc dot gnu dot org 2007-07-19 07:28 -------
And here is the patch which fixes the issue:
Index: fold-const.c
===================================================================
--- fold-const.c (revision 126739)
+++ fold-const.c (working copy)
@@ -3278,6 +3278,9 @@
{
tree t = fold_convert (type, result);
+ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted))
+ return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted));
+
if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
@@ -3291,6 +3294,9 @@
{
tree t = fold_convert (type, result);
+ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted))
+ return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted));
+
if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32813