i’m a bit concerned because when compiling otp_src_27.2.2 the following warning is reported by gcc:
CC obj/aarch64-unknown-linux-gnu/opt/jit/dist.o
In file included from ../include/internal/gcc/ethread.h:347,
from ../include/internal/ethread.h:389,
from beam/erl_threads.h:252,
from beam/sys.h:539,
from beam/dist.c:37:
In function 'ethr_native_atomic64_set_relb',
inlined from 'ethr_atomic_set_mb' at ../include/internal/ethr_atomics.h:4019:5,
inlined from 'erts_dist_command' at beam/dist.c:3867:5:
../include/internal/gcc/ethr_atomic.h:144:5: warning: '__atomic_store_8' writing 8 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
144 | __atomic_store_n(&var->value, value, __ATOMIC_RELEASE);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I also get this with gcc-14.2 on aarch64-linux-gnu. gcc has had false warnings before, and I believe this one is too, but I can’t prove that right now.
It does look like a gcc bug. I’ve reduced the preprocessed code for dist.c on aarch64-linux-gnu to a 42 line test case that triggers this warning on both aarch64 and x86_64. Small code changes that don’t change the semantics of the source silence the warning.
On the gcc side, the warning is valid, but the message is misleading and it doesn’t always trigger as it should. There’s a gcc upstream bug report about that.
On the BEAM side, there is a missing NULL pointer check in the source code. However, it appears that it “cannot” happen at runtime. There is a pull request on GH now to silence the warning.