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

            Bug ID: 101630
           Summary: ICE with -Wall: in get_constant, at
                    c-family/c-format.c:325
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cnsun at uwaterloo dot ca
  Target Milestone: ---

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/configure
--enable-languages=c,c++,lto --enable-checking-yes --enable-multiarch
--prefix=/scratch/software/gcc-trunk --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210726 (experimental) [master revision
:c09cf6429:124bb55777c280a85d0c72ec13e293a32917a6b9] (GCC)

$ cat mutant.c
printf(char[][], ...) { printf(printf); }

$ gcc-trunk -Wall mutant.c
mutant.c:1:12: error: array type has incomplete element type ‘char[]’
    1 | printf(char[][], ...) { printf(printf); }
      |            ^
mutant.c:1:12: note: declaration of multidimensional array must have bounds for
all dimensions except the first
mutant.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    1 | printf(char[][], ...) { printf(printf); }
      | ^~~~~~
mutant.c: In function ‘printf’:
mutant.c:1:32: error: type of formal parameter 1 is incomplete
    1 | printf(char[][], ...) { printf(printf); }
      |                                ^~~~~~
mutant.c:1:1: internal compiler error: in get_constant, at
c-family/c-format.c:325
    1 | printf(char[][], ...) { printf(printf); }
      | ^~~~~~
0x675c97 get_constant
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c-family/c-format.c:325
0x675c97 get_constant
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c-family/c-format.c:313
0x9b061e decode_format_attr
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c-family/c-format.c:377
0x9b2894 check_function_format(tree_node const*, tree_node*, int, tree_node**,
vec<unsigned int, va_heap, vl_ptr>*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c-family/c-format.c:1173
0x9a1c86 check_function_arguments(unsigned int, tree_node const*, tree_node
const*, int, tree_node**, vec<unsigned int, va_heap, vl_ptr>*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c-family/c-common.c:5981
0x92a0eb build_function_call_vec(unsigned int, vec<unsigned int, va_heap,
vl_ptr>, tree_node*, vec<tree_node*, va_gc, vl_embed>*, vec<tree_node*, va_gc,
vl_embed>*, tree_node*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-typeck.c:3195
0x94b27a c_parser_postfix_expression_after_primary
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:10505
0x93bc65 c_parser_postfix_expression
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:10178
0x946141 c_parser_unary_expression
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:8224
0x94780f c_parser_cast_expression
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:8066
0x947abf c_parser_binary_expression
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:7869
0x948da8 c_parser_conditional_expression
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:7592
0x949420 c_parser_expr_no_commas
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:7507
0x9496b1 c_parser_expression
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:10641
0x949e87 c_parser_expression_conv
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:10680
0x95d2f3 c_parser_statement_after_labels
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:6249
0x95f594 c_parser_compound_statement_nostart
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:5788
0x95fc84 c_parser_compound_statement
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:5597
0x961672 c_parser_declaration_or_fndef
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:2539
0x968ff3 c_parser_external_declaration
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/c/c-parser.c:1777
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.





Note that with -Wall, gcc-trunk also crashes though with a different stack
trace.

mutant.c:1:12: error: array type has incomplete element type ‘char[]’
    1 | printf(char[][], ...) { printf(printf); }
      |            ^
mutant.c:1:12: note: declaration of multidimensional array must have bounds for
all dimensions except the first
mutant.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    1 | printf(char[][], ...) { printf(printf); }
      | ^~~~~~
mutant.c: In function ‘printf’:
mutant.c:1:32: error: type of formal parameter 1 is incomplete
    1 | printf(char[][], ...) { printf(printf); }
      |                                ^~~~~~
mutant.c:1:25: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in useless_type_conversion_p, at gimple-expr.c:259
    1 | printf(char[][], ...) { printf(printf); }
      |                         ^~~~~~
0x7d0759 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/tree.c:8736
0x6dd971 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/tree.h:3496
0x6dd971 useless_type_conversion_p(tree_node*, tree_node*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimple-expr.c:259
0xc583d7 types_compatible_p
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimple-expr.h:67
0xc583d7 gimplify_addr_expr
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:6235
0xc4adbf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:14270
0xc53ba9 gimplify_call_expr
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:3454
0xc4b45f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:14195
0xc4dc6a gimplify_stmt(tree_node**, gimple**)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:6869
0xc4e49e gimplify_bind_expr
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:1426
0xc4b47c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:14424
0xc4dc6a gimplify_stmt(tree_node**, gimple**)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:6869
0xc4f293 gimplify_body(tree_node*, bool)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:15456
0xc4f6e1 gimplify_function_tree(tree_node*)
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/gimplify.c:15610
0xaa2777 cgraph_node::analyze()
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/cgraphunit.c:670
0xaa5651 analyze_functions
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/cgraphunit.c:1234
0xaa6131 symbol_table::finalize_compilation_unit()
        /tmp/tmp.Tt2AkDfoq0-gcc-builder/gcc/gcc/cgraphunit.c:2508
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to