public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/109598] New: ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc
@ 2023-04-23  2:56 anbu1024.me at gmail dot com
  2023-04-24  7:12 ` [Bug c/109598] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: anbu1024.me at gmail dot com @ 2023-04-23  2:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109598
           Summary: ICE: tree check: expected array_type, have error_mark
                    in array_ref_low_bound, at tree.cc
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anbu1024.me at gmail dot com
  Target Milestone: ---

gcc (GCC) 13.0.1 20230219 snapshot ICEs when compiling the following testcase

$ gcc --version
gcc (GCC) 13.0.1 20230219 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--------------------------------

$ cat 2.c

extern char g[];

char *foo(void)
{
  return &g[0];
}

char *g(void)
{
  return &g[1];
}

--------------------------------

$ gcc 2.c 
2.c:9:7: error: ‘g’ redeclared as different kind of symbol
    9 | char *g(void)
      |       ^
2.c:2:13: note: previous declaration of ‘g’ with type ‘char[]’
    2 | extern char g[];
      |             ^
2.c: In function ‘g’:
2.c:11:12: error: subscripted value is neither array nor pointer nor vector
   11 |   return &g[1];
      |            ^
2.c: In function ‘foo’:
2.c:6:12: internal compiler error: tree check: expected array_type, have
error_mark in array_ref_low_bound, at tree.cc:12782
    6 |   return &g[0];
      |           ~^~~
0x840178 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc-13-20230219/gcc/tree.cc:8909
0x8499ae tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc-13-20230219/gcc/tree.h:3530
0x8499ae array_ref_low_bound(tree_node*)
        ../../gcc-13-20230219/gcc/tree.cc:12782
0xc8caf9 gimplify_compound_lval
        ../../gcc-13-20230219/gcc/gimplify.cc:3219
0xc875fe gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16313
0xc8e602 gimplify_addr_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:6561
0xc8805d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16408
0xc9a465 gimplify_modify_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:6153
0xc879e1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16361
0xc8a316 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:7219
0xc96670 gimplify_and_add(tree_node*, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:492
0xc96670 gimplify_return_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:1680
0xc87d0a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16623
0xc8a316 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:7219
0xc8aa47 gimplify_bind_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:1430
0xc87c95 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16562
0xca912e gimplify_stmt(tree_node**, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:7219
0xca912e gimplify_body(tree_node*, bool)
        ../../gcc-13-20230219/gcc/gimplify.cc:17623
0xca958a gimplify_function_tree(tree_node*)
        ../../gcc-13-20230219/gcc/gimplify.cc:17822
0xad7fa7 cgraph_node::analyze()
        ../../gcc-13-20230219/gcc/cgraphunit.cc:676
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug c/109598] ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc
  2023-04-23  2:56 [Bug c/109598] New: ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc anbu1024.me at gmail dot com
@ 2023-04-24  7:12 ` rguenth at gcc dot gnu.org
  2023-04-24  9:50 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-24  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-04-24
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  While it's possible to fend this off during gimplification it would
be nice if the frontend wouldn't emit

 <addr_expr 0x7ffff737a2e0
    type <pointer_type 0x7ffff71eee70
        type <integer_type 0x7ffff71e33f0 char public QI
            size <integer_cst 0x7ffff71c4e88 constant 8>
            unit-size <integer_cst 0x7ffff71c4ea0 constant 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff71e33f0 precision:8 min <integer_cst 0x7ffff71c4ed0 -128> max
<integer_cst 0x7ffff71c4f00 127>
            pointer_to_this <pointer_type 0x7ffff71eee70>>
        unsigned DI
        size <integer_cst 0x7ffff71c4d98 constant 64>
        unit-size <integer_cst 0x7ffff71c4db0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff71eee70 reference_to_this <reference_type 0x7ffff7364dc8>>
    constant
    arg:0 <array_ref 0x7ffff71c2508 type <integer_type 0x7ffff71e33f0 char>

        arg:0 <var_decl 0x7ffff71d2cf0 g type <error_mark 0x7ffff71c4d80>
            addressable used public external read BLK t.c:1:13
            align:8 warn_if_not_align:0 context <translation_unit_decl
0x7ffff71d1d20 t.c> chain <function_decl 0x7ffff736f800 foo>>
        arg:1 <integer_cst 0x7ffff71e7138 constant 0>
        t.c:5:12 start: t.c:5:11 finish: t.c:5:14>
    t.c:5:10 start: t.c:5:10 finish: t.c:5:14>

specifically

    arg:0 <array_ref 0x7ffff71c2508 type <integer_type 0x7ffff71e33f0 char>
        arg:0 <var_decl 0x7ffff71d2cf0 g type <error_mark 0x7ffff71c4d80>

note the array_ref has type 'char' but the var_decl has type error_mark.

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

* [Bug c/109598] ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc
  2023-04-23  2:56 [Bug c/109598] New: ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc anbu1024.me at gmail dot com
  2023-04-24  7:12 ` [Bug c/109598] " rguenth at gcc dot gnu.org
@ 2023-04-24  9:50 ` marxin at gcc dot gnu.org
  2023-04-24 18:19 ` [Bug c/109598] [12/13/14 Regression] " pinskia at gcc dot gnu.org
  2023-07-23 12:50 ` roger at nextmovesoftware dot com
  3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-04-24  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org,
                   |                            |sayle at gcc dot gnu.org

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

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

* [Bug c/109598] [12/13/14 Regression] ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc
  2023-04-23  2:56 [Bug c/109598] New: ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc anbu1024.me at gmail dot com
  2023-04-24  7:12 ` [Bug c/109598] " rguenth at gcc dot gnu.org
  2023-04-24  9:50 ` marxin at gcc dot gnu.org
@ 2023-04-24 18:19 ` pinskia at gcc dot gnu.org
  2023-07-23 12:50 ` roger at nextmovesoftware dot com
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-24 18:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0
            Summary|ICE: tree check: expected   |[12/13/14 Regression] ICE:
                   |array_type, have error_mark |tree check: expected
                   |in array_ref_low_bound, at  |array_type, have error_mark
                   |tree.cc                     |in array_ref_low_bound, at
                   |                            |tree.cc

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #2)
> Started with r12-3278-g823685221de986.

I figured that caused this issue. 

> it would be nice if the frontend wouldn't emit

If the C front-end had its own AST, then it would be easier but it does not.
Maybe we should not gimplify things if there was an error (from the front-end);
that might help.

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

* [Bug c/109598] [12/13/14 Regression] ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc
  2023-04-23  2:56 [Bug c/109598] New: ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc anbu1024.me at gmail dot com
                   ` (2 preceding siblings ...)
  2023-04-24 18:19 ` [Bug c/109598] [12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-07-23 12:50 ` roger at nextmovesoftware dot com
  3 siblings, 0 replies; 5+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-07-23 12:50 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
                 CC|                            |roger at nextmovesoftware dot com

--- Comment #4 from Roger Sayle <roger at nextmovesoftware dot com> ---
This issue has been fixed on mainline (for GCC 14), by the patch for PR 110699.

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

end of thread, other threads:[~2023-07-23 12:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23  2:56 [Bug c/109598] New: ICE: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc anbu1024.me at gmail dot com
2023-04-24  7:12 ` [Bug c/109598] " rguenth at gcc dot gnu.org
2023-04-24  9:50 ` marxin at gcc dot gnu.org
2023-04-24 18:19 ` [Bug c/109598] [12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-07-23 12:50 ` roger at nextmovesoftware dot com

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