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

            Bug ID: 91173
           Summary: [9 Regression] ICE: in int_mode_for_mode, at
                    stor-layout.c:403
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gzauhar at gmail dot com
  Target Milestone: ---

GCC-9.1.0 ICEs with following test case (I used c-reduce to reduce it) when
compiling with -O1 flag. It compiles fine with -O0. Snapshot gcc-9-20190706
also ICEs. GCC-8.3.0 works fine.
------------------------------------------------------
class a {
  int b;
  void *c;

public:
  bool aa();
  int &ab() {
    if (aa()) {
      void *d(c);
      return static_cast<int *>(d)[b];
    }
    return *(int *)0;
  }
};
typedef enum {E} e;
class f : public a {
  int g;

public:
  int ac() {
    if (g)
      return 1;
    return ac();
  }
};
int *ad;
struct h {
  static int ae(e, int *m) {
    f ag;
    int *ah;
    while (!0) {
      ad = &ag.ab();
      ah = ad + ag.ac();
      while (ad < ah)
        *m = *ad++;
    }
  }
};
template <class, class>
void i(int *, int *, int, int *, e n, int *o) {
  h::ae(n, o);
}
int aq, ar, as, at, au;
void aw() { i<int, bool>(&aq, &ar, as, &at, (e)0, &au); }
------------------------------------------------------
$ /home/gz/apps/gcc-9.1.0/bin/g++ -Wall -Wextra -pedantic -O0 -c crash.cpp
$ /home/gz/apps/gcc-9.1.0/bin/g++ -Wall -Wextra -pedantic -O1 -c crash.cpp
during RTL pass: expand
crash.cpp: In function 'void aw()':
crash.cpp:35:14: internal compiler error: in int_mode_for_mode, at
stor-layout.c:403
   35 |         *m = *ad++;
      |              ^~~~~
0x6160eb int_mode_for_mode(machine_mode)
        ../.././gcc/stor-layout.c:403
0x91aebd emit_move_via_integer
        ../.././gcc/expr.c:3357
0x92301f emit_move_insn_1(rtx_def*, rtx_def*)
        ../.././gcc/expr.c:3718
0x923332 emit_move_insn(rtx_def*, rtx_def*)
        ../.././gcc/expr.c:3786
0x9097e3 copy_to_reg(rtx_def*)
        ../.././gcc/explow.c:602
0x909a81 memory_address_addr_space(machine_mode, rtx_def*, unsigned char)
        ../.././gcc/explow.c:472
0x91feac expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../.././gcc/expr.c:10270
0x92a3eb store_expr(tree_node*, rtx_def*, int, bool, bool)
        ../.././gcc/expr.c:5674
0x92b5e0 expand_assignment(tree_node*, tree_node*, bool)
        ../.././gcc/expr.c:5436
0x82d6b8 expand_gimple_stmt_1
        ../.././gcc/cfgexpand.c:3752
0x82d6b8 expand_gimple_stmt
        ../.././gcc/cfgexpand.c:3850
0x8325c7 expand_gimple_basic_block
        ../.././gcc/cfgexpand.c:5886
0x83495e execute
        ../.././gcc/cfgexpand.c:6509
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.

$ /home/gz/apps/gcc-9.1.0/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/gz/apps/gcc-9.1.0/bin/g++
COLLECT_LTO_WRAPPER=/home/gz/apps/gcc-9.1.0/libexec/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/home/gz/apps/gcc-9.1.0
--enable-languages=c,c++ --disable-multilib --disable-nls
--enable-linker-build-id --enable-default-pie
Thread model: posix
gcc version 9.1.0 (GCC)

Reply via email to