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

            Bug ID: 105069
           Summary: [12 regression] sh-elf internal compiler errors and
                    test failures with -Os
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jscott at posteo dot net
  Target Milestone: ---

Hi,

This seems to be a regression as compared to GCC 11. When building a bare-metal
compiler for sh-elf (Newlib or an ISO C standard library is not required), GCC
aborts with an internal compiler error:

gcc.c-torture/compile/pr104327.c:13:1: internal compiler error:
‘global_options’ are modified in local context
   13 | {
      | ^

There are numerous test suite failures that this causes:
gcc.c-torture/compile/pr104327.c (no special flags needed, since -Os is set via
an attribute)
and for the following, building with -Os is necessary:
gcc.c-torture/compile/pr58332.c
gcc.c-torture/compile/pr81360.c
gcc.c-torture/compile/pr84425.c

Here is a one-line reproducer:
cat bar.c
[[gnu::optimize("Os")]] int main(void) {}
$ sh-elf-gcc bar.c
bar.c:1:1: internal compiler error: ‘global_options’ are modified in local
context
    1 | [[gnu::optimize("Os")]] int main(void) {}
      | ^
0x7f231098a7fc __libc_start_main
        ../csu/libc-start.c:332

This occurs using the latest Git master on an x86_64 Debian Bullseye GNU/Linux
system. I'm not sure that this issue lies in the C frontend, so please reassign
wherever appropriate.

I discovered this issue running the test suite to upgrade the Debian gcc-sh-elf
package.

Reply via email to