From: Willy Tarreau Date: Wed, 1 Jul 2026 13:09:10 +0000 (+0200) Subject: BUILD: quic: workaround a gcc bug saying "maybe used uninitialized" when USE_TRACE=0 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/control.html?a=commitdiff_plain;h=4fe06d8c83e4a5ac6fea144cdfddd145f49ed929;p=haproxy.git BUILD: quic: workaround a gcc bug saying "maybe used uninitialized" when USE_TRACE=0 In quic_transport_params_store(), we call qc_early_transport_params_cpy() if edata_accepted is set, which copies one by one all tx_params into the locally allocated etps struct, and later after updates we call qc_early_transport_params_validate() to check if they changed. It turns out that when USE_TRACE is disabled, gcc 4 to 13 are confused and believe that one or several of the fields compared in the later function might be used uninitialized. A careful code inspection proves that this is not the case. Setting them to zero in the _cpy() function makes the warning disappear, it's really an issue related to variable propagation it seems, which can explain why it doesn't happen with traces (code is a bit more complex). Gcc-13 only emits a warning about a single field, and gcc-14 completely solved it. Playing with consts, __maybe_unused etc has no effect. One thing works however, it is to mark the _validate() function noinline. In this case it is implemented normally and the compiler doesn't put its nose into the propagation path and doesn't complain. Such comments are always scary because one may seriously wonder whether the compiler emits valid code when it says this... It should be backported to 3.4 which experiences the same warning with USE_TRACE=0. --- diff --git a/src/quic_tp.c b/src/quic_tp.c index b38c5318a..1b6d1015f 100644 --- a/src/quic_tp.c +++ b/src/quic_tp.c @@ -937,6 +937,11 @@ void qc_early_transport_params_reuse(struct quic_conn *qc, TRACE_PROTO("\nTX(remote) transp. params.", QUIC_EV_TRANSP_PARAMS, qc, p); } +// noinline: workaround a gcc 4-13 bug reporting "maybe used uninitialized" on +// some fields of *e when called from quic_transport_params_store() despite +// being set early via qc_early_transport_params_cpy(). Reproducible with +// USE_TRACE=0. gcc<13 has many warnings. 13 has a single one, 14 is OK. +__attribute__((noinline)) static int qc_early_tranport_params_validate(struct quic_conn *qc, struct quic_transport_params *p, struct quic_early_transport_params *e)