Attention is currently required from: Hung-Te Lin, Xi Chen, Paul Menzel, Xixi Chen, Yu-Ping Wu. Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/61334 )
Change subject: soc/mediatek: Save dram info to cbmem ......................................................................
Patch Set 25:
(1 comment)
File src/soc/mediatek/common/memory.c:
https://review.coreboot.org/c/coreboot/+/61334/comment/1f4500a9_bf1ba563 PS22, Line 123: p = (void *)((uintptr_t)mc + sizeof(*mc)); The problem with C99 variable-length arrays is that they make sizeof() illegal. I believe GCC happens to still allow it and return the right thing for them, but it's not officially supported, whereas sizeof() for the zero-length arrays is well-defined (by GCC).
Anyway, this should work. It has always worked... I'm not sure what's suddenly going on here, this seems to have to do with the recent upgrade to GCC 11. (There have been some other strange bugs with that too, see CB:62828.) The warning description for -Warray-bounds explicitly says:
-Warray-bounds=1: This is the warning level of -Warray-bounds and is enabled by -Wall; higher levels are not, and must be explicitly requested.
-Warray-bounds=2: This warning level also warns about out of bounds access for arrays at the end of a struct and for arrays accessed through pointers. This warning level may give a larger number of false positives and is deactivated by default.
coreboot doesn't set -Warray-bounds=2 explicitly, so we should only be using -Warray-bounds=1, and this is an array at the end of a struct so it should be excluded by this check.
Doesn't look like you've actually tried uploading this that way (or am I overlooking the Jenkins comment?), so are you sure that fails in the described way for the official compiler version? Only for one specific architecture or all of them? I've tried reproducing this to a minimal test case, but I can't really make it show up:
struct mystruct { int a; struct { int b; } c[0]; };
int test(struct mystruct *x) { return x->c[2].b; }
Not sure if I'm trying the wrong compiler version or there's something more complicated needed to trigger this? We should figure out exactly what causes it and then decide what to do (i.e. temporarily disable -Warray-bounds or something while we file a bug with GCC). Rewriting all clean variable-length structure accesses into raw pointer arithmetic doesn't seem the right way to deal with this to me.