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

            Bug ID: 100576
           Summary: ICE at -O1 and above: in decompose, at wide-int.h:984
           Product: gcc
           Version: tree-ssa
            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.BriefQJ2R3-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 20210511 (experimental) [master revision
:61d4686bb:71d38ec80008afdbb9a059253407d80598b765c0] (GCC)

$ cat mutant.c
const char si16_4_rep[] = {0x12};
eq_si16_x() {
  int n, b = sizeof si16_4_rep;
  const *p, *q = si16_4_rep;
  n += memcmp(p, q, b);
  if (n)
    __builtin_abort();
}

$ gcc-trunk -O1 mutant.c
mutant.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    2 | eq_si16_x() {
      | ^~~~~~~~~
mutant.c: In function ‘eq_si16_x’:
mutant.c:4:10: warning: type defaults to ‘int’ in declaration of ‘p’
[-Wimplicit-int]
    4 |   const *p, *q = si16_4_rep;
      |          ^
mutant.c:4:14: warning: type defaults to ‘int’ in declaration of ‘q’
[-Wimplicit-int]
    4 |   const *p, *q = si16_4_rep;
      |              ^
mutant.c:4:18: warning: initialization of ‘const int *’ from incompatible
pointer type ‘const char *’ [-Wincompatible-pointer-types]
    4 |   const *p, *q = si16_4_rep;
      |                  ^~~~~~~~~~
mutant.c:5:8: warning: implicit declaration of function ‘memcmp’
[-Wimplicit-function-declaration]
    5 |   n += memcmp(p, q, b);
      |        ^~~~~~
mutant.c:1:1: note: include ‘<string.h>’ or provide a declaration of ‘memcmp’
  +++ |+#include <string.h>
    1 | const char si16_4_rep[] = {0x12};
mutant.c:5:21: warning: ‘memcmp’ argument 3 type is ‘int’ where ‘long unsigned
int’ is expected in a call to built-in function declared without prototype
[-Wbuiltin-declaration-mismatch]
    5 |   n += memcmp(p, q, b);
      |                     ^
<built-in>: note: built-in ‘memcmp’ declared here
during RTL pass: expand
mutant.c:5:8: internal compiler error: in decompose, at wide-int.h:984
    5 |   n += memcmp(p, q, b);
      |        ^~~~~~~~~~~~~~~
0x679a02 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.BriefQJ2R3-gcc-builder/gcc/gcc/wide-int.h:984
0x67e3d1 wi::int_traits<generic_wide_int<wide_int_storage> >::decompose(long*,
unsigned int, generic_wide_int<wide_int_storage> const&)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/tree.h:3479
0x67e3d1 wide_int_ref_storage<true,
false>::wide_int_ref_storage<generic_wide_int<wide_int_storage>
>(generic_wide_int<wide_int_storage> const&, unsigned int)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/wide-int.h:1034
0x67e3d1 generic_wide_int<wide_int_ref_storage<true, false>
>::generic_wide_int<generic_wide_int<wide_int_storage>
>(generic_wide_int<wide_int_storage> const&, unsigned int)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/wide-int.h:790
0x67e3d1 bool wi::ltu_p<generic_wide_int<wide_int_ref_storage<false, false> >,
generic_wide_int<wide_int_storage>
>(generic_wide_int<wide_int_ref_storage<false, false> > const&,
generic_wide_int<wide_int_storage> const&)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/wide-int.h:1937
0x67e3d1 bool wi::leu_p<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.BriefQJ2R3-gcc-builder/gcc/gcc/wide-int.h:1979
0x67e3d1 check_nul_terminated_array(tree_node*, tree_node*, tree_node*)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/builtins.c:1228
0xa0ad9e check_access(tree_node*, tree_node*, tree_node*, tree_node*,
tree_node*, access_mode, access_data const*)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/builtins.c:4669
0xa0d0e7 check_read_access
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/builtins.c:4909
0xa0e1a1 check_read_access
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/builtins.c:4904
0xa0e1a1 expand_builtin_memcmp
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/builtins.c:7049
0xa12154 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/builtins.c:10226
0xb6243c expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/expr.c:11405
0xb6cf58 store_expr(tree_node*, rtx_def*, int, bool, bool)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/expr.c:5986
0xb6e59f expand_assignment(tree_node*, tree_node*, bool)
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/expr.c:5721
0xa3cb0b expand_call_stmt
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/cfgexpand.c:2841
0xa3cb0b expand_gimple_stmt_1
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/cfgexpand.c:3847
0xa3cb0b expand_gimple_stmt
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/cfgexpand.c:4011
0xa42809 expand_gimple_basic_block
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/cfgexpand.c:6048
0xa4445f execute
        /tmp/tmp.BriefQJ2R3-gcc-builder/gcc/gcc/cfgexpand.c:6732
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