Bug 102760 - ICE: in decompose, at wide-int.h:984
Summary: ICE: in decompose, at wide-int.h:984
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-checking, ice-on-invalid-code, needs-bisection
: 107320 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-15 02:50 UTC by Chengnian Sun
Modified: 2024-03-08 04:00 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-10-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chengnian Sun 2021-10-15 02:50:16 UTC
$ 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.gzh6IUhxke-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 20211014 (experimental) [master -gee9fa8a57] (GCC)

$ cat mutant.c
int isascii(enum mm2);
f1(char *type) { isascii(*type); }

$ gcc-trunk -w mutant.c
mutant.c: In function ‘f1’:
mutant.c:2:26: error: type of formal parameter 1 is incomplete
    2 | f1(char *type) { isascii(*type); }
      |                          ^~~~~
mutant.c:2:18: internal compiler error: in decompose, at wide-int.h:984
    2 | f1(char *type) { isascii(*type); }
      |                  ^~~~~~~~~~~~~~
0x84c5a6 wi::int_traits<generic_wide_int<wide_int_ref_storage<false, false> > >::decompose(long*, unsigned int, generic_wide_int<wide_int_ref_storage<false, false> > const&)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/wide-int.h:984
0x87be6e wi::int_traits<generic_wide_int<wide_int_ref_storage<false, false> > >::decompose(long*, unsigned int, generic_wide_int<wide_int_ref_storage<false, false> > const&)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/tree.h:3612
0x87be6e wide_int_ref_storage<false, false>::wide_int_ref_storage<generic_wide_int<wide_int_ref_storage<false, false> > >(generic_wide_int<wide_int_ref_storage<false, false> > const&, unsigned int)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/wide-int.h:1034
0x87be6e generic_wide_int<wide_int_ref_storage<false, false> >::generic_wide_int<generic_wide_int<wide_int_ref_storage<false, false> > >(generic_wide_int<wide_int_ref_storage<false, false> > const&, unsigned int)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/wide-int.h:790
0x87be6e wi::binary_traits<generic_wide_int<wide_int_storage>, generic_wide_int<wide_int_ref_storage<false, false> >, wi::int_traits<generic_wide_int<wide_int_storage> >::precision_type, wi::int_traits<generic_wide_int<wide_int_ref_storage<false, false> > >::precision_type>::result_type wi::bit_and_not<generic_wide_int<wide_int_storage>, generic_wide_int<wide_int_ref_storage<false, false> > >(generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_ref_storage<false, false> > const&)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/wide-int.h:2343
0x87be6e gimple_simplify_BIT_AND_EXPR
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc-build-trunk/gcc/gimple-match.c:124016
0x15a7906 gimple_simplify
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc-build-trunk/gcc/gimple-match.c:142649
0x15a930c gimple_resimplify2
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimple-match-head.c:320
0x15d451a gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*))
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimple-match-head.c:959
0xc68926 fold_stmt_1
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimple-fold.c:6212
0xca9b40 gimplify_modify_expr
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:6129
0xc9c7d3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:14584
0xca04da gimplify_stmt(tree_node**, gimple**)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:7018
0xca26c6 gimplify_and_add(tree_node*, gimple**)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:494
0xca26c6 internal_get_tmp_var
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:647
0xc9bdf7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:15587
0xc9c67a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:15350
0xca04da gimplify_stmt(tree_node**, gimple**)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:7018
0xca0d0e gimplify_bind_expr
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:1426
0xc9d00c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int)
	/tmp/tmp.gzh6IUhxke-gcc-builder/gcc/gcc/gimplify.c:14785
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.
Comment 1 Andrew Pinski 2021-10-15 03:12:21 UTC
There is a types which are not the same issue.

(gdb) p debug_tree(*expr_p)
 <init_expr 0x7ffff737de88
    type <integer_type 0x7ffff725f5e8 int public SI
        size <integer_cst 0x7ffff7244f78 constant 32>
        unit-size <integer_cst 0x7ffff7244f90 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff725f5e8 precision:32 min <integer_cst 0x7ffff7244f30 -2147483648> max <integer_cst 0x7ffff7244f48 2147483647>
        pointer_to_this <pointer_type 0x7ffff7267a80>>
    side-effects
    arg:0 <ssa_name 0x7ffff724fe10 type <integer_type 0x7ffff725f5e8 int>

        def_stmt _2 = _1 & -128;
        version:2>
    arg:1 <bit_and_expr 0x7ffff737de60 type <integer_type 0x7ffff725f5e8 int>

        arg:0 <ssa_name 0x7ffff724fdc8 type <integer_type 0x7ffff725f3f0 char>

            def_stmt _1 = *type;
            version:1>
        arg:1 <integer_cst 0x7ffff7263420 constant -128>>
    t.c:3:18 start: t.c:3:18 finish: t.c:3:31>

This shows up in GCC 11 (with checking enabled).
Comment 2 Martin Liška 2021-10-15 08:26:53 UTC
Likely triggered with r7-821-gc7986356a1ca8e8e.
Comment 3 Marc Glisse 2021-10-15 08:46:44 UTC
(In reply to Martin Liška from comment #2)
> Likely triggered with r7-821-gc7986356a1ca8e8e.

From Andrew's comment, it looks like the bug is before that transformation, since it receives a bit_and_expr of type int with an argument of type char, no?
Comment 4 Andrew Pinski 2021-10-15 21:21:09 UTC
(In reply to Marc Glisse from comment #3)
> (In reply to Martin Liška from comment #2)
> > Likely triggered with r7-821-gc7986356a1ca8e8e.
> 
> From Andrew's comment, it looks like the bug is before that transformation,
> since it receives a bit_and_expr of type int with an argument of type char,
> no?

Correct the bug was latent before that commit and I had already figured that commit had exposed it but I did not want to report though.
Comment 5 Andrew Pinski 2022-10-20 15:41:15 UTC
*** Bug 107320 has been marked as a duplicate of this bug. ***
Comment 6 David Binderman 2023-01-25 18:21:16 UTC
I see very similar for this legal C code:

int li_4, li_5, us_8;
unsigned char func_7_ptr_13, func_7_uc_14;
void func_7_ptr_18() {
  if (li_5) {
    for (;;)
      ;
    short s_15;
    for (; func_7_uc_14;) {
      us_8 = 7;
      for (; us_8; us_8 += 1)
      lblD2AF1FAB:
        if (us_8)
          li_4 = 1;
      func_7_uc_14 += func_7_ptr_18;
      if (func_7_ptr_13 & 1 && (func_7_uc_14 &= func_7_ptr_13))
        s_15 %= func_7_uc_10li_19(s_15);
    }
  }
  goto lblD2AF1FAB;
}

when compiled as follows:

$ ~/gcc/results//bin/gcc -c -O2 -Wall bug876.c 
bug876.c: In function ‘func_7_ptr_18’:
bug876.c:14:20: warning: assignment to ‘unsigned char’ from ‘void (*)()’ makes integer from pointer without a cast [-Wint-conversion]
   14 |       func_7_uc_14 += func_7_ptr_18;
      |                    ^~
bug876.c:16:17: warning: implicit declaration of function ‘func_7_uc_10li_19’ [-Wimplicit-function-declaration]
   16 |         s_15 %= func_7_uc_10li_19(s_15);
      |                 ^~~~~~~~~~~~~~~~~
during GIMPLE pass: uninit
bug876.c:3:6: internal compiler error: in decompose, at wide-int.h:984
    3 | void func_7_ptr_18() {
Comment 7 Andrew Pinski 2023-01-25 18:23:57 UTC
(In reply to David Binderman from comment #6)
> I see very similar for this legal C code:

That seems like a different issue, please file it seperately.
Comment 8 David Binderman 2023-01-25 18:29:30 UTC
(In reply to Andrew Pinski from comment #7)
> (In reply to David Binderman from comment #6)
> > I see very similar for this legal C code:
> 
> That seems like a different issue, please file it seperately.

Done, see 108547.
Comment 9 Andrew Pinski 2024-03-08 04:00:19 UTC
I can't reproduce this on the trunk any more.