From: Willy Tarreau Date: Thu, 11 Apr 2024 14:34:03 +0000 (+0200) Subject: BUILD: atomic: fix peers build regression on gcc < 4.7 after recent changes X-Git-Tag: v3.0-dev8~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a9ccf5b2583d2b8c20b7a022e5a40dc9e2aec39;p=thirdparty%2Fhaproxy.git BUILD: atomic: fix peers build regression on gcc < 4.7 after recent changes Recent commit 4c1480f13b ("MINOR: stick-tables: mark the seen stksess with a flag "seen"") introduced a build regression on older versions of gcc before 4.7. This is in the old __sync_ API, the HA_ATOMIC_LOAD() implementation uses an intermediary return value called "ret" that is of the same name as the variable passed in argument to the macro in the aforementioned commit. As such, the compiler complains with a cryptic error: src/peers.c: In function 'peer_teach_process_stksess_lookup': src/peers.c:1502: error: invalid type argument of '->' (have 'int') The solution is to avoid referencing the argument in the expression and using an intermediary variable for the pointer as done elsewhere in the code. It seems there's no other place affected with this. It probably does not need to be backported since this code is antique and very rarely used nowadays. --- diff --git a/include/haproxy/atomic.h b/include/haproxy/atomic.h index 93b143c94d..146f2ad77e 100644 --- a/include/haproxy/atomic.h +++ b/include/haproxy/atomic.h @@ -199,10 +199,11 @@ #define HA_ATOMIC_LOAD(val) \ ({ \ - typeof(*(val)) ret = \ - ({ __sync_synchronize(); *(volatile typeof(val))val; }); \ + typeof((val)) __val_load = (val); \ + typeof(*(val)) __ret_val = \ + ({ __sync_synchronize(); *(volatile typeof(__val_load))__val_load; }); \ __sync_synchronize(); \ - ret; \ + __ret_val; \ }) #define HA_ATOMIC_STORE(val, new) \