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

            Bug ID: 90256
           Summary: Optimizer with interrupt routines
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nulano at nulano dot eu
  Target Milestone: ---

Created attachment 46248
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46248&action=edit
verbose compiler output (MSYS2 GCC 8.3.0)

Enabling optimizer (either -Os or -O2) triggers error "interrupt service
routine can't be called directly" when two interrupt routines have identical
code.


Code to reproduce:

    int rand();
    int x = 0;
    __attribute((interrupt)) void isr1(void*) {
        for (int i = 0; i < 10; i++)
            x ^= rand();
    }
    // isr2 is identical to isr1
    __attribute((interrupt)) void isr2(void*) {
        for (int i = 0; i < 10; i++)
            x ^= rand();
    }

- compile with "g++ -mgeneral-regs-only -S" -> works
- compile with "g++ -mgeneral-regs-only -S -Os" -> error


Tested on:
- Windows 7 64-bit MSYS2-W64-X86_64 GCC 7.3.0
- Windows 7 64-bit MSYS2-W64-X86_64 GCC 8.3.0
- Linux Mint / Ubuntu GCC 7.3.0

Reply via email to