public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106628] New: Missed folding with COMPOUND_EXPR due to C frontend bugs
@ 2022-08-15 13:57 rguenth at gcc dot gnu.org
  2022-08-15 16:04 ` [Bug c/106628] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-15 13:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106628

            Bug ID: 106628
           Summary: Missed folding with COMPOUND_EXPR due to C frontend
                    bugs
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

Doing

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 4f4ec81c8d4..698f115507a 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -12595,14 +12595,9 @@ fold_binary_loc (location_t loc, enum tree_code code,
tree type,
       return NULL_TREE;

     case COMPOUND_EXPR:
-      /* When pedantic, a compound expression can be neither an lvalue
-        nor an integer constant expression.  */
-      if (TREE_SIDE_EFFECTS (arg0) || TREE_CONSTANT (arg1))
+      if (TREE_SIDE_EFFECTS (arg0))
        return NULL_TREE;
-      /* Don't let (0, 0) be null pointer constant.  */
-      tem = integer_zerop (arg1) ? build1_loc (loc, NOP_EXPR, type, arg1)
-                                : fold_convert_loc (loc, type, arg1);
-      return tem;
+      return op1;

     case ASSERT_EXPR:
       /* An ASSERT_EXPR should never be passed to fold_binary.  */


results in missed diagnostics:

FAIL: gcc.dg/array-5.c bad vla handling (test for bogus messages, line 40)
FAIL: gcc.dg/c99-const-expr-12.c (test for excess errors)
FAIL: gcc.dg/pr61096-1.c  (test for errors, line 29)
FAIL: gcc.dg/pr61096-1.c (test for excess errors)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/106628] Missed folding with COMPOUND_EXPR due to C frontend bugs
  2022-08-15 13:57 [Bug c/106628] New: Missed folding with COMPOUND_EXPR due to C frontend bugs rguenth at gcc dot gnu.org
@ 2022-08-15 16:04 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-15 16:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106628

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-08-15
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |diagnostic,
                   |                            |missed-optimization

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-15 16:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 13:57 [Bug c/106628] New: Missed folding with COMPOUND_EXPR due to C frontend bugs rguenth at gcc dot gnu.org
2022-08-15 16:04 ` [Bug c/106628] " pinskia at gcc dot gnu.org

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