Bug 97980 - [10/11 Regression] wrong code with "-O3 -fno-dce -fno-inline-functions-called-once -fno-inline-small-functions -fno-tree-ccp -fno-tree-dce -fno-tree-vrp" since r10-3311-gff6686d2e5f797d6
Summary: [10/11 Regression] wrong code with "-O3 -fno-dce -fno-inline-functions-called...
Status: RESOLVED DUPLICATE of bug 93385
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P2 normal
Target Milestone: 10.3
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2020-11-25 07:46 UTC by suochenyao@163.com
Modified: 2020-11-26 12:01 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.3.0
Known to fail: 10.2.0, 11.0
Last reconfirmed: 2020-11-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description suochenyao@163.com 2020-11-25 07:46:28 UTC
*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
int a=2;
static int b(int *c) { (0 >= *c) & (a--); return 0; }
int main() {
  int d=0;
  b(&d);
}
*******************************************************************************
gcc version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/suocy/bin/gcc-dev/bin/gcc
COLLECT_LTO_WRAPPER=/home/suocy/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/suocy/bin/gcc-dev/ --disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201124 (experimental) (GCC)
*******************************************************************************
Command Lines:
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O3 -fno-dce -fno-inline-functions-called-once -fno-inline-small-functions -fno-tree-ccp -fno-tree-dce -fno-tree-vrp a.c
a.c: In function ‘b’:
a.c:2:34: warning: value computed is not used [-Wunused-value]
    2 | static int b(int *c) { (0 >= *c) & (a--); return 0; }
      |                        ~~~~~~~~~~^~~~~~~
a.c: In function ‘b.constprop.isra’:
a.c:2:30: warning: ‘c’ is used uninitialized [-Wuninitialized]
    2 | static int b(int *c) { (0 >= *c) & (a--); return 0; }
      |                              ^~
$ ./a.out
Segmentation fault
Comment 1 Andrew Pinski 2020-11-25 08:00:33 UTC
I think it is due to -fno-tree-dce .
Comment 2 Martin Liška 2020-11-25 08:18:10 UTC
Started with r10-3311-gff6686d2e5f797d6.
Comment 3 Martin Jambor 2020-11-26 12:01:25 UTC
This is quite clearly a duplicate of PR 93385 (IPA-SRA relies on DCE).  Let me try again to come up with a more acceptable patch to fix it.

*** This bug has been marked as a duplicate of bug 93385 ***