From 8d957c56b33241b8e93c27d7a698d8079b402285 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 19 Sep 2024 19:53:19 +0200 Subject: [PATCH] unix: work around arm-linux-gnueabihf-gcc bug (#4565) Both gcc 11 and 12 emit wrong code for a function call pointer in one very specific context. Fixes: https://github.com/libuv/libuv/issues/4532 --- src/unix/fs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index 263d4bbc..239ecda1 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -487,7 +487,10 @@ static ssize_t uv__preadv_or_pwritev(int fd, atomic_store_explicit(cache, (uintptr_t) p, memory_order_relaxed); } - f = p; + /* Use memcpy instead of `f = p` to work around a compiler bug, + * see https://github.com/libuv/libuv/issues/4532 + */ + memcpy(&f, &p, sizeof(p)); return f(fd, bufs, nbufs, off); }