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

            Bug ID: 90802
           Summary: optimization accepts invalid
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

My gcc is 10.0.0, and the code is:

typedef unsigned int uint32_t;
struct CPUPPCState
{
 uint32_t fpscr;
};
register struct CPUPPCState *env __asm__ ("ebp");
void
helpersetbit (uint32_t bit)
{
 switch (bit)
 switch (env->fpscr)
 {
 }
}

Gcc rejects it:

source>: In function 'void helpersetbit(uint32_t)':

<source>:11:15: warning: statement will never be executed
[-Wswitch-unreachable]

   11 |  switch (env->fpscr)

      |          ~~~~~^~~~~

<source>:8:1: error: frame pointer required, but reserved

    8 | helpersetbit (uint32_t bit)

      | ^~~~~~~~~~~~

<source>:6:30: note: for 'env'

    6 | register struct CPUPPCState *env __asm__ ("ebp");

      |                              ^~~

Compiler returned: 1

However, it accepts the above code, with the following parameters:

gcc -fomit-frame-pointer | gcc -Os | gcc -O3 | gcc -O1 | g++
-fomit-frame-pointer | g++ -Os | g++ -O3 | g++ -O1 | 


The above error message contains a warning for dead code. I submitted another
bug, which can be related:

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

Reply via email to