public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923
@ 2022-10-18 17:44 gscfq@t-online.de
  2022-10-19  6:49 ` [Bug c/107307] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gscfq@t-online.de @ 2022-10-18 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107307
           Summary: ICE tree check: expected class 'type', have
                    'exceptional' (error_mark) in
                    canonicalize_component_ref, at gimplify.cc:2923
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started with r12 between 20210822 and 20210905 :


$ cat z1.c
void f ()
{
  const struct { int a[1]; } b;
  int *c = b.a;
  int *b;
}


$ gcc-13-20221016 -c z1.c
z1.c: In function 'f':
z1.c:4:12: warning: initialization discards 'const' qualifier from pointer
target type [-Wdiscarded-qualifiers]
    4 |   int *c = b.a;
      |            ^
z1.c:5:8: error: conflicting type qualifiers for 'b'
    5 |   int *b;
      |        ^
z1.c:3:30: note: previous declaration of 'b' with type 'const struct
<anonymous>'
    3 |   const struct { int a[1]; } b;
      |                              ^
z1.c:4:13: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923
    4 |   int *c = b.a;
      |            ~^~
0x6acb6d tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc/tree.cc:8886
0xb8578e tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc/tree.h:3649
0xb8578e canonicalize_component_ref
        ../../gcc/gimplify.cc:2923
0xba3857 gimplify_compound_lval
        ../../gcc/gimplify.cc:3326
0xb9753a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:16280
0xbaa91a gimplify_addr_expr
        ../../gcc/gimplify.cc:6529
0xb9913d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:16375
0xba931f gimplify_modify_expr
        ../../gcc/gimplify.cc:6121
0xb998f7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:16328
0xb9d7d8 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7187
0xba2343 gimplify_and_add(tree_node*, gimple**)
        ../../gcc/gimplify.cc:492
0xba2343 gimplify_decl_expr
        ../../gcc/gimplify.cc:1938
0xb988b2 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:16525
0xb9d7d8 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7187
0xb98bcb gimplify_statement_list
        ../../gcc/gimplify.cc:2021
0xb98bcb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:16773
0xb9d7d8 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7187
0xb9e163 gimplify_bind_expr
        ../../gcc/gimplify.cc:1430
0xb990da gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:16529
0xb9d7d8 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7187

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

* [Bug c/107307] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
@ 2022-10-19  6:49 ` marxin at gcc dot gnu.org
  2022-10-19  7:19 ` [Bug middle-end/107307] [12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-19  6:49 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE tree check: expected    |ICE tree check: expected
                   |class 'type', have          |class 'type', have
                   |'exceptional' (error_mark)  |'exceptional' (error_mark)
                   |in                          |in
                   |canonicalize_component_ref, |canonicalize_component_ref,
                   |at gimplify.cc:2923         |at gimplify.cc:2923 since
                   |                            |r12-3278-g823685221de986af
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |jsm28 at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org,
                   |                            |sayle at gcc dot gnu.org
   Last reconfirmed|                            |2022-10-19

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-3278-g823685221de986af.

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

* [Bug middle-end/107307] [12/13 Regression] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
  2022-10-19  6:49 ` [Bug c/107307] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af marxin at gcc dot gnu.org
@ 2022-10-19  7:19 ` rguenth at gcc dot gnu.org
  2022-11-15 19:37 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-19  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.3
          Component|c                           |middle-end
            Summary|ICE tree check: expected    |[12/13 Regression] ICE tree
                   |class 'type', have          |check: expected class
                   |'exceptional' (error_mark)  |'type', have 'exceptional'
                   |in                          |(error_mark) in
                   |canonicalize_component_ref, |canonicalize_component_ref,
                   |at gimplify.cc:2923 since   |at gimplify.cc:2923 since
                   |r12-3278-g823685221de986af  |r12-3278-g823685221de986af
           Priority|P3                          |P4
           Keywords|                            |ice-on-invalid-code

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

* [Bug middle-end/107307] [12/13 Regression] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
  2022-10-19  6:49 ` [Bug c/107307] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af marxin at gcc dot gnu.org
  2022-10-19  7:19 ` [Bug middle-end/107307] [12/13 Regression] " rguenth at gcc dot gnu.org
@ 2022-11-15 19:37 ` pinskia at gcc dot gnu.org
  2022-11-17 20:24 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-15 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug middle-end/107307] [12/13 Regression] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-11-15 19:37 ` pinskia at gcc dot gnu.org
@ 2022-11-17 20:24 ` pinskia at gcc dot gnu.org
  2022-11-17 20:41 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-17 20:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Simple fix:
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index f06ce3cc77a..bd772c15bec 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -3319,7 +3319,9 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p,
     }

   /* If the outermost expression is a COMPONENT_REF, canonicalize its type. 
*/
-  if ((fallback & fb_rvalue) && TREE_CODE (*expr_p) == COMPONENT_REF)
+  if (ret != GS_ERROR
+      && (fallback & fb_rvalue)
+      && TREE_CODE (*expr_p) == COMPONENT_REF)
     {
       canonicalize_component_ref (expr_p);
     }


I am going to submit this and PR 106764 together.

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

* [Bug middle-end/107307] [12/13 Regression] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-11-17 20:24 ` pinskia at gcc dot gnu.org
@ 2022-11-17 20:41 ` pinskia at gcc dot gnu.org
  2022-11-18 17:03 ` cvs-commit at gcc dot gnu.org
  2022-11-18 17:05 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-17 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=106765

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually the patch which works better:
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index f06ce3cc77a..c62a966e918 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -3272,6 +3272,8 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p,
   tret = gimplify_expr (p, pre_p, post_p, is_gimple_min_lval,
                        fallback | fb_lvalue);
   ret = MIN (ret, tret);
+  if (ret == GS_ERROR)
+    return GS_ERROR;

   /* Step 2a: if we have component references we do not support on
      registers then make sure the base isn't a register.  Of course



Also fixes PR 106765.

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

* [Bug middle-end/107307] [12/13 Regression] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-11-17 20:41 ` pinskia at gcc dot gnu.org
@ 2022-11-18 17:03 ` cvs-commit at gcc dot gnu.org
  2022-11-18 17:05 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-18 17:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:bd0c9d9e706adaeea0d96152daade0a6819a8715

commit r13-4143-gbd0c9d9e706adaeea0d96152daade0a6819a8715
Author: Andrew Pinski <apinski@marvell.com>
Date:   Thu Nov 17 22:08:07 2022 +0000

    Fix PRs 106764, 106765, and 107307, all ICE after invalid re-declaration

    The problem here is the gimplifier returns GS_ERROR but
    in some cases we don't check that soon enough and try
    to do other work which could crash.
    So the fix in these two cases is to return GS_ERROR
    early if the gimplify_* functions had return GS_ERROR.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    Thanks,
    Andrew Pinski

    gcc/ChangeLog:

            PR c/106764
            PR c/106765
            PR c/107307
            * gimplify.cc (gimplify_compound_lval): Return GS_ERROR
            if gimplify_expr had return GS_ERROR.
            (gimplify_call_expr): Likewise.

    gcc/testsuite/ChangeLog:

            PR c/106764
            PR c/106765
            PR c/107307
            * gcc.dg/redecl-19.c: New test.
            * gcc.dg/redecl-20.c: New test.
            * gcc.dg/redecl-21.c: New test.

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

* [Bug middle-end/107307] [12/13 Regression] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af
  2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-11-18 17:03 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18 17:05 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-18 17:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|12.3                        |13.0

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed for GCC 13. Since this is an ICE after error, no reason to backport it.

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

end of thread, other threads:[~2022-11-18 17:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 17:44 [Bug c/107307] New: ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 gscfq@t-online.de
2022-10-19  6:49 ` [Bug c/107307] ICE tree check: expected class 'type', have 'exceptional' (error_mark) in canonicalize_component_ref, at gimplify.cc:2923 since r12-3278-g823685221de986af marxin at gcc dot gnu.org
2022-10-19  7:19 ` [Bug middle-end/107307] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-11-15 19:37 ` pinskia at gcc dot gnu.org
2022-11-17 20:24 ` pinskia at gcc dot gnu.org
2022-11-17 20:41 ` pinskia at gcc dot gnu.org
2022-11-18 17:03 ` cvs-commit at gcc dot gnu.org
2022-11-18 17:05 ` 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).