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

            Bug ID: 116390
           Summary: Another ICE for avrtiny and optimization
           Product: gcc
           Version: 15.0
               URL: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=116389
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dv at vollmann dot ch
  Target Milestone: ---
            Target: avr

Created attachment 58939
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58939&action=edit
Produced by -freport-bug

This ICE happened when I tried to strip down the source for
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116389>.

For -O3 and -O4 it produces an ICE very similar to #116389 (the file for O3 is
attached).
For -O2 it produces:
during RTL pass: final
ice.cc: In function 'void badFoo()':
ice.cc:70:1: internal compiler error: Segmentation fault
   70 | }
      | ^
0x1cf6290 internal_error(char const*, ...)
        /ssd1/build/src/gcc/gcc/diagnostic-global-context.cc:491
0xfca7af crash_signal
        /ssd1/build/src/gcc/gcc/toplev.cc:321
0x7ff7ade1d58f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xbf92e1 output_operand(rtx_def*, int)
        /ssd1/build/src/gcc/gcc/final.cc:3624
0xbf9ee0 output_asm_insn(char const*, rtx_def**)
        /ssd1/build/src/gcc/gcc/final.cc:3524
0x13e5557 output_movsisf(rtx_insn*, rtx_def**, int*)
        /ssd1/build/src/gcc/gcc/config/avr/avr.cc:5923
0xbfd340 final_scan_insn_1
        /ssd1/build/src/gcc/gcc/final.cc:2773
0xbfd908 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
        /ssd1/build/src/gcc/gcc/final.cc:2886
0xbfdb37 final_1
        /ssd1/build/src/gcc/gcc/final.cc:1977
0xbfe634 rest_of_handle_final
        /ssd1/build/src/gcc/gcc/final.cc:4239
0xbfe634 execute
        /ssd1/build/src/gcc/gcc/final.cc:4317

and claims: "The bug is not reproducible, so it is likely a hardware or OS
problem." (which is bogus, it's 100% reproducible).

Due to this difference I submit this as separate bug, but feel free to mark it
as duplicate of #116389.

Here's the complete source for reference:

--- start source
struct MyStruct
{
    int i;
};

void f_ic(int, char);
void f_pi(char const *, int);
void f_iic(int, int, char);

const MyStruct *f_rms();

char *f_rcp();
int f_ri();


void badFoo()
{
    const MyStruct* ps = f_rms();
    const char* pc = f_rcp();

    unsigned n1 = f_rcp() - pc;

    if (n1)
    {
        long n2 = n1 - ps->i;
        if (n2 > 0)
        {
            if (f_ri())
                n2 = n1;

            if (f_ri())
            {
                f_iic(1, 2 * n2, ' ');
            }
            else
                f_pi(pc, n2);
        }
        if (ps->i > 0)
        {
            if (n2 >= 0)
                f_pi(pc + n2, ps->i);
            else
            {
                f_ic(n2, ' ');
            }
        }

        const int which = f_ri();
        switch (which)
        {
        case 1:
            if (f_ri())
                f_rcp()[1] = ' ';
            break;

        case 2:
            f_pi(f_rcp(), 1);
            break;

        case 3:
            if (f_ri() && n1 < 0)
                f_ic(n1, ' ');
            else
                f_rcp()[1] = ' ';
            break;

        }
    }
}
--- end source

Reply via email to