Open ueno opened 2 years ago
Extracted out and trimmed down:
int table[2][2] = { {1, 2}, {3, 4} };
int f(const int* c) { return c[0]; }
int main() { return f(table[1]); }
test.c:2:23: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
int f(const int* c) { return c[0]; }
^~~~~~~~~~~
Curiously, passing table[0]
or dropping the const
modifier makes the warning go away.
With clang version 13.0.0 (Fedora 13.0.0-3.fc35), I got the following warning when compiling under scan-build:
The code path is as follows:
subkey
is called with the 3rd argumenti
set to 0LSX
is called with the 3rd argumentc
pointing tokuz_key_table[i + 2]
kuz_key_table
is defined as a constant 2-dimensional array (static const uint8_t kuz_key_table[32][16]
) and the above access never involves out-of-bounds. Perhaps #49948 might be related.