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

            Bug ID: 96235
           Summary: Segmentation fault with "-Og -fno-dce -fno-tree-dce
                    -finline-small-functions -fipa-sra"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: suochenyao at 163 dot com
  Target Milestone: ---

Hi,

I've got a problem when using gcc new trunk version. I compile the following
source code with "-Og -fno-dce -fno-tree-dce -finline-small-functions
-fipa-sra" on x86_64 GNU/Linux. It reports "Segmentation fault (core dumped)".
If I using "gcc -O2 -Wall -Wextra", it will only say "variable ‘g’ set but not
used". But with only optimization level, the problem will not occur. And if I
reduce any one of "-fno-dce -fno-tree-dce -finline-small-functions -fipa-sra",
this problem will not occur as well.
Looking forward to your reply, Thanks!

$ gcc --version
$ gcc (GCC) 11.0.0 20200717 (experimental)
$ 
$ gcc -O2  -Wall -Wextra -fno-strict-aliasing -fwrapv a.c
a.c: In function ‘e’:
a.c:5:7: warning: variable ‘g’ set but not used [-Wunused-but-set-variable]
    5 |   int g = (b >= *f);
      |       ^
$
$ gcc -Og -fno-dce -fno-tree-dce -finline-small-functions -fipa-sra a.c;
./a.out
Segmentation fault (core dumped)
$ 
$ gcc -O0 a.c; ./a.out
$ gcc -O1 a.c; ./a.out
$ gcc -O2 a.c; ./a.out
$ gcc -O3 a.c; ./a.out
$ gcc -Og a.c; ./a.out
$ gcc -Os a.c; ./a.out
$ 
$ gcc -O1 -fno-dce -fno-tree-dce -finline-small-functions -fipa-sra a.c;
./a.out
$ gcc -O2 -fno-dce -fno-tree-dce -finline-small-functions -fipa-sra a.c;
./a.out
$ gcc -O3 -fno-dce -fno-tree-dce -finline-small-functions -fipa-sra a.c;
./a.out
$ gcc -Os -fno-dce -fno-tree-dce -finline-small-functions -fipa-sra a.c;
./a.out
$ gcc -Og -fno-tree-dce -finline-small-functions -fipa-sra a.c; ./a.out
$ gcc -Og -fno-dce -finline-small-functions -fipa-sra a.c; ./a.out
$ gcc -Og -fno-dce -fno-tree-dce -fipa-sra a.c; ./a.out
$ gcc -Og -fno-dce -fno-tree-dce -finline-small-functions a.c; ./a.out
$
-------------------------------
int b=1;
long d=1L;
long c=1L;
static int e(long *f) {
  int g = (b >= *f);
  g = (d && c);
  return 0;
}
int main() {
  long a=1L;
  e(&a);
  return 0;
}

Reply via email to