------- 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