https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129261
Bug ID: 129261
Summary: [17 Regression] byte[216]' may be used uninitialized
[-Werror=maybe-uninitialized] with -O3
-march=x86-64-v2
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gnu.ojxq8 at dralias dot com
Target Milestone: ---
This regression only happens with a byte count of exactly 216, and only with
-O3 opt and only on x86-64-v2.
godbolt: https://godbolt.org/z/WM8MnjbM3
code:
#include <stdlib.h>
enum { BYTE_COUNT = 216 };
int main(void)
{
char* my_static_ctx = malloc(BYTE_COUNT);
if (!my_static_ctx) return 1;
for (int i = 0; i < BYTE_COUNT; i++) my_static_ctx[i] = '*';
for (int i = 0; i < BYTE_COUNT; i++)
if (my_static_ctx[i] != '*') return 1;
}
cmd:
# /opt/gcc-latest/bin/gcc -std=c17 -Wextra -Werror -O3 -march=x86-64-v2 -c
/tmp/test.c
/tmp/test.c: In function ‘main’:
/tmp/test.c:9:26: error: ‘my_static_ctx[216]’ may be used uninitialized
[-Werror=maybe-uninitialized]
9 | if (my_static_ctx[i] != '*') return 1;
| ~~~~~~~~~~~~~^~~
cc1: all warnings being treated as errors
This was minimized from trying to compile
https://github.com/bitcoin-core/secp256k1 with -O3.