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

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
I had already dealt with this problem in the pretty printer in r11-6621 (the
same way as in comment #2) but it regressed with Jakub's subsequent changes in
r11-6729.  It's also not the only regression that Jakub's change seems to have
caused.  Instrumenting GCC to print every MEM_REF it sees in
maybe_warn_operand() in tree-ssa-uninit.c causes the ICE below that I didn't
get when testing r11-6621.

I agree the pretty printer should as much as possible try to behave robustly
for bad MEM_REfs, if only to make debugging easier.

...
during GIMPLE pass: *early_warn_uninitialized
In function ‘void selftest::verify_clear_bit_region()’:
canonical types differ for identical types ‘unsigned char [3]’ and ‘unsigned
char [3]’
 5499 | } // namespace selftest
      | ^
0xe61a0a comptypes(tree_node*, tree_node*, int)
        /src/gcc/master/gcc/cp/typeck.c:1540
0xe61c07 same_type_ignoring_top_level_qualifiers_p(tree_node*, tree_node*)
        /src/gcc/master/gcc/cp/typeck.c:1576
0xaf4fe0 cxx_types_compatible_p(tree_node*, tree_node*)
        /src/gcc/master/gcc/cp/cp-objcp-common.c:123
0xf4f98e c_fold_indirect_ref_for_warn
        /src/gcc/master/gcc/c-family/c-pretty-print.c:1829
0xf50695 print_mem_ref
        /src/gcc/master/gcc/c-family/c-pretty-print.c:1953
0xf515bd c_pretty_printer::unary_expression(tree_node*)
        /src/gcc/master/gcc/c-family/c-pretty-print.c:2171
0xbad752 dump_expr
        /src/gcc/master/gcc/cp/error.c:2422
0xbb0ed8 expr_to_string(tree_node*)
        /src/gcc/master/gcc/cp/error.c:3188
0xbb4ffd cp_printer
        /src/gcc/master/gcc/cp/error.c:4356
0x2cba14f pp_format(pretty_printer*, text_info*)
        /src/gcc/master/gcc/pretty-print.c:1475
0x2c8ffd5 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        /src/gcc/master/gcc/diagnostic.c:1244
0x2c90675 diagnostic_impl
        /src/gcc/master/gcc/diagnostic.c:1406
0x2c90ad3 inform(unsigned int, char const*, ...)
        /src/gcc/master/gcc/diagnostic.c:1485
0x1c107c7 maybe_warn_operand
        /src/gcc/master/gcc/tree-ssa-uninit.c:255
0x1c11bf1 warn_uninitialized_vars
        /src/gcc/master/gcc/tree-ssa-uninit.c:660
0x1c17374 execute_early_warn_uninitialized
        /src/gcc/master/gcc/tree-ssa-uninit.c:3092
0x1c173f2 execute
        /src/gcc/master/gcc/tree-ssa-uninit.c:3127
...

The ICE is for this statement

  MEM <unsigned char[3]> [(char * {ref-all})&in] = MEM <unsigned char[3]>
[(char * {ref-all})&orig];

and the following value of e in print_mem_ref:

 <mem_ref 0x7fffe88d5a78
    type <array_type 0x7fffe74c9e70
        type <integer_type 0x7fffea815348 unsigned char sizes-gimplified public
unsigned type_6 QI
            size <integer_cst 0x7fffea7f7fa8 constant 8>
            unit-size <integer_cst 0x7fffea7f7fc0 constant 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea815348 precision:8 min <integer_cst 0x7fffea7f7fd8 0> max <integer_cst
0x7fffea7f7f78 255>
            pointer_to_this <pointer_type 0x7fffe902a690>>
        BLK
        size <integer_cst 0x7fffea818360 constant 24>
        unit-size <integer_cst 0x7fffe9198048 constant 3>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe74c9e70
        domain <integer_type 0x7fffe8f7ad20 type <integer_type 0x7fffea815000
sizetype>
            sizes-gimplified type_6 DI
            size <integer_cst 0x7fffea7f7eb8 constant 64>
            unit-size <integer_cst 0x7fffea7f7ed0 constant 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe8f7ad20 precision:64 min <integer_cst 0x7fffea7f7ee8 0> max <integer_cst
0x7fffea818090 2>>>

    arg:0 <addr_expr 0x7fffe6e09360
        type <pointer_type 0x7fffe6e01540 type <array_type 0x7fffe6e015e8>
            unsigned DI size <integer_cst 0x7fffea7f7eb8 64> unit-size
<integer_cst 0x7fffea7f7ed0 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe6e01540>

        arg:0 <var_decl 0x7fffe6e02510 orig type <array_type 0x7fffe6e015e8>
            used tree_1 tree_2 tree_6 read decl_5 BLK
/src/gcc/master/gcc/gimple-ssa-store-merging.c:5442:17 size <integer_cst
0x7fffea818360 24> unit-size <integer_cst 0x7fffe9198048 3>
            align:8 warn_if_not_align:0 context <function_decl 0x7fffe6e03700
verify_clear_bit_region> chain <var_decl 0x7fffe6e025a0 in>>
        /src/gcc/master/gcc/gimple-ssa-store-merging.c:5445:15 start:
/src/gcc/master/gcc/gimple-ssa-store-merging.c:5445:15 finish:
/src/gcc/master/gcc/gimple-ssa-store-merging.c:5445:18>
    arg:1 <integer_cst 0x7fffe7590cf0 type <pointer_type 0x7fffe74291f8>
constant 0>>

Reply via email to