https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98074
Bug ID: 98074
Summary: [9/10 Regression] C Wrong code at O2~Os
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
Target Milestone: ---
$cat small.c
#include <stdint.h>
#include <stdio.h>
struct {
int64_t a;
} b;
struct c {
signed d : 9;
signed a : 21;
signed e : 1;
};
int f, g;
uint16_t h() {
struct c aa = {0, -4};
int64_t *ab = &b.a;
for (; g; g = 1)
;
*ab = 5 && aa.e;
return f;
}
int main() {
h();
printf("%d\n", (int)b.a);
}
$gcc-10 small.c ; ./a.out
0
$gcc-10 -O2 small.c ; ./a.out
1
$gcc-10 -O3 small.c ; ./a.out
1
This is only reproduced in GCC 10.x versions, and the GCC-trunk or GCC-9
downwards version seems fine to it.
BTW, may I ask how to check whether a wrong-code bug is already reported or
not? It's not like a crash that can be easily known as the duplicated one. I
will be appreciated if you can give me some tips. Thanks.
Best,
Haoxin