public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/109618] New: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc
@ 2023-04-25  5:53 anbu1024.me at gmail dot com
  2023-04-25  6:37 ` [Bug c/109618] " 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-25  5:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109618
           Summary: ICE: tree check: expected class ‘type’, have
                    ‘exceptional’ (error_mark) in
                    generic_simplify_CONVERT_EXPR, at generic-match.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: ---

$ cat test.c 

int foo()
{
  const unsigned int var_1 = 2;

  char var_5[var_1];

  int var_1[10];

  return sizeof(var_5);
}


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

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

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

$ gcc test.c  
test.c: In function ‘foo’:
test.c:8:7: error: conflicting type qualifiers for ‘var_1’
    8 |   int var_1[10];
      |       ^~~~~
test.c:4:22: note: previous definition of ‘var_1’ with type ‘unsigned int’
    4 |   const unsigned int var_1 = 2;
      |                      ^~~~~
test.c :10:3: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at
generic-match.cc:28499
   10 |   return sizeof(var_5);
      |   ^~~~~~
0x840637 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc-13-20230219/gcc/tree.cc:8959
0x8abac0 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc-13-20230219/gcc/tree.h:3653
0x8abac0 generic_simplify_CONVERT_EXPR
        gcc-13-20230219-build/gcc/generic-match.cc:28499
0xbf6848 fold_unary_loc(unsigned int, tree_code, tree_node*, tree_node*)
        ../../gcc-13-20230219/gcc/fold-const.cc:9341
0xbf8079 fold_build1_loc(unsigned int, tree_code, tree_node*, tree_node*)
        ../../gcc-13-20230219/gcc/fold-const.cc:13778
0x9429bb c_expr_sizeof_expr(unsigned int, c_expr)
        ../../gcc-13-20230219/gcc/c/c-typeck.cc:3096
0x97ef46 c_parser_sizeof_expression
        ../../gcc-13-20230219/gcc/c/c-parser.cc:8910
0x97ef46 c_parser_unary_expression
        ../../gcc-13-20230219/gcc/c/c-parser.cc:8803
0x97fdef c_parser_cast_expression
        ../../gcc-13-20230219/gcc/c/c-parser.cc:8672
0x9800df c_parser_binary_expression
        ../../gcc-13-20230219/gcc/c/c-parser.cc:8440
0x98154b c_parser_conditional_expression
        ../../gcc-13-20230219/gcc/c/c-parser.cc:8138
0x981d24 c_parser_expr_no_commas
        ../../gcc-13-20230219/gcc/c/c-parser.cc:8052
0x981fd1 c_parser_expression
        ../../gcc-13-20230219/gcc/c/c-parser.cc:11379
0x982717 c_parser_expression_conv
        ../../gcc-13-20230219/gcc/c/c-parser.cc:11419
0x97858b c_parser_statement_after_labels
        ../../gcc-13-20230219/gcc/c/c-parser.cc:6674
0x9798e4 c_parser_compound_statement_nostart
        ../../gcc-13-20230219/gcc/c/c-parser.cc:6296
0x99f164 c_parser_compound_statement
        ../../gcc-13-20230219/gcc/c/c-parser.cc:6105
0x9a10cb c_parser_declaration_or_fndef
        ../../gcc-13-20230219/gcc/c/c-parser.cc:2841
0x9a8a1b c_parser_external_declaration
        ../../gcc-13-20230219/gcc/c/c-parser.cc:1925
0x9a93f3 c_parser_translation_unit
        ../../gcc-13-20230219/gcc/c/c-parser.cc:1779
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/109618] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc
  2023-04-25  5:53 [Bug c/109618] New: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc anbu1024.me at gmail dot com
@ 2023-04-25  6:37 ` rguenth at gcc dot gnu.org
  2023-04-27  6:59 ` [Bug c/109618] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc since r12-3278-g823685221de986 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-25  6:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We're folding

 <nop_expr 0x7ffff6fdc420
    type <integer_type 0x7ffff6e51000 sizetype public unsigned DI
        size <integer_cst 0x7ffff6e32d98 constant 64>
        unit-size <integer_cst 0x7ffff6e32db0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6e51000 precision:64 min <integer_cst 0x7ffff6e32dc8 0> max <integer_cst
0x7ffff6e334c0 18446744073709551615>>
    readonly
    arg:0 <var_decl 0x7ffff6e40cf0 var_1 type <error_mark 0x7ffff6e32d80>
        readonly used unsigned read SI t.c:3:22
        size <integer_cst 0x7ffff6e32fd8 constant 32>
        unit-size <integer_cst 0x7ffff6e55000 constant 4>
        align:32 warn_if_not_align:0 context <function_decl 0x7ffff6fe0400 foo>
initial <integer_cst 0x7ffff6fe9960 2>>>

to a size_type_node.

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

* [Bug c/109618] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc since r12-3278-g823685221de986
  2023-04-25  5:53 [Bug c/109618] New: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc anbu1024.me at gmail dot com
  2023-04-25  6:37 ` [Bug c/109618] " rguenth at gcc dot gnu.org
@ 2023-04-27  6:59 ` marxin at gcc dot gnu.org
  2024-03-23 20:27 ` [Bug c/109618] [12/13/14 Regression] " pinskia at gcc dot gnu.org
  2024-03-23 20:38 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-04-27  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |sayle at gcc dot gnu.org
            Summary|ICE: tree check: expected   |ICE: tree check: expected
                   |class ‘type’, have          |class ‘type’, have
                   |‘exceptional’ (error_mark)  |‘exceptional’ (error_mark)
                   |in                          |in
                   |generic_simplify_CONVERT_EX |generic_simplify_CONVERT_EX
                   |PR, at generic-match.cc     |PR, at generic-match.cc
                   |                            |since
                   |                            |r12-3278-g823685221de986

--- 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/109618] [12/13/14 Regression] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc since r12-3278-g823685221de986
  2023-04-25  5:53 [Bug c/109618] New: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc anbu1024.me at gmail dot com
  2023-04-25  6:37 ` [Bug c/109618] " rguenth at gcc dot gnu.org
  2023-04-27  6:59 ` [Bug c/109618] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc since r12-3278-g823685221de986 marxin at gcc dot gnu.org
@ 2024-03-23 20:27 ` pinskia at gcc dot gnu.org
  2024-03-23 20:38 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-23 20:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.4
            Summary|ICE: tree check: expected   |[12/13/14 Regression] ICE:
                   |class ‘type’, have          |tree check: expected class
                   |‘exceptional’ (error_mark)  |‘type’, have ‘exceptional’
                   |in                          |(error_mark) in
                   |generic_simplify_CONVERT_EX |generic_simplify_CONVERT_EX
                   |PR, at generic-match.cc     |PR, at generic-match.cc
                   |since                       |since
                   |r12-3278-g823685221de986    |r12-3278-g823685221de986

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

* [Bug c/109618] [12/13/14 Regression] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc since r12-3278-g823685221de986
  2023-04-25  5:53 [Bug c/109618] New: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc anbu1024.me at gmail dot com
                   ` (2 preceding siblings ...)
  2024-03-23 20:27 ` [Bug c/109618] [12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2024-03-23 20:38 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-23 20:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This one seems harder to fix.

We have:
```
(gdb) p debug_tree(value)
 <nop_expr 0x7ffff79ad5c0
    type <integer_type 0x7ffff7822000 sizetype public unsigned DI
        size <integer_cst 0x7ffff7802f48 constant 64>
        unit-size <integer_cst 0x7ffff7802f60 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7822000 precision:64 min <integer_cst 0x7ffff7802f78 0> max <integer_cst
0x7ffff78035e0 18446744073709551615>>
    readonly
    arg:0 <var_decl 0x7ffff7810c60 var_1 type <error_mark 0x7ffff7802f30>
        readonly used unsigned read SI t2.c:3:22
        size <integer_cst 0x7ffff7824198 constant 32>
        unit-size <integer_cst 0x7ffff78241b0 constant 4>
        align:32 warn_if_not_align:0 context <function_decl 0x7ffff79b3600 foo>
initial <integer_cst 0x7ffff79bbbe8 2>>>
```

Before calling fold.
So we turn var_1's type to error_mark when merging the 2 decls (after an
error).
But then the rest of the front-end/middle-end is still not ready for types all
the time to have an error_mark.

Note I don't think we should revert r12-3278 even though it has had a lot of
fall out because it produces better error recovery in general.

Note for this simplified testcase we could look through the NOP_EXPR in
c_sizeof_alignof but a more complex one which does s/var_5[var_1]/var_5[13 *
var_1]/, we can't as we get:
(sizetype) ((unsigned int) var_1 * 13)

And that one ICEs in tree_nonzero_bits.
    CASE_CONVERT:
      return wide_int::from (tree_nonzero_bits (TREE_OPERAND (t, 0)),
                             TYPE_PRECISION (TREE_TYPE (t)),
                             TYPE_SIGN (TREE_TYPE (TREE_OPERAND (t, 0))));

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

end of thread, other threads:[~2024-03-23 20:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25  5:53 [Bug c/109618] New: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc anbu1024.me at gmail dot com
2023-04-25  6:37 ` [Bug c/109618] " rguenth at gcc dot gnu.org
2023-04-27  6:59 ` [Bug c/109618] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in generic_simplify_CONVERT_EXPR, at generic-match.cc since r12-3278-g823685221de986 marxin at gcc dot gnu.org
2024-03-23 20:27 ` [Bug c/109618] [12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-03-23 20:38 ` 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).