From: Kienan Stewart Date: Tue, 6 Aug 2024 15:32:57 +0000 (-0400) Subject: Fix: Compilation failure deducing type of `auto` variables in GCC 4.8 X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=93afa33ce85dc4672d8a77c3279060b86a6b0e16;p=lttng-tools.git Fix: Compilation failure deducing type of `auto` variables in GCC 4.8 Observed issue ============== When compiling with GCC 4.8.5 or GCC 5.5.0 on SLES12SP5, the following error happens: ``` save.cpp: In function 'int save_agent_events(config_writer*, agent*)': save.cpp:1185:43: error: use of 'agent_event' before deduction of 'auto' lttng::urcu::lfht_iteration_adapter(*agent->events->ht)) { ^ save.cpp:1187:26: error: creating pointer to member of non-class type '' save.cpp:1187:26: note: invalid template non-type parameter In file included from ../../../src/vendor/fmt/core.h:3316:0, from ../../../src/common/format.hpp:20, from ../../../src/common/error.hpp:13, from ../../../src/common/common.hpp:12, from snapshot.hpp:13, from consumer.hpp:12, from session.hpp:11, from kernel.hpp:13, from save.cpp:10: ``` Cause ===== This appears to be a limitation in older versions of GCC. I did not find specific commit(s) or bugs which hilight the issue, but compilation of this code works as of GCC 6.5.0 on SLES12SP5. Previous point releases of GCC 6.x were not tested. Solution ======== Explicitly define the type of the pointer and the type passed to `lttng::urcu::lftht_iteration_adapter` so the compiler does not have to perform type deduction. Known drawbacks =============== None. Change-Id: I71c5937a38336756ece4f396ea5ba7af7f3d36c3 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/agent.cpp b/src/bin/lttng-sessiond/agent.cpp index ee93713e1..4be1c32fc 100644 --- a/src/bin/lttng-sessiond/agent.cpp +++ b/src/bin/lttng-sessiond/agent.cpp @@ -1544,8 +1544,8 @@ void agent_by_event_notifier_domain_ht_destroy() return; } - for (auto *agent : - lttng::urcu::lfht_iteration_adapter( + for (struct agent *agent : + lttng::urcu::lfht_iteration_adapter( *the_trigger_agents_ht_by_domain->ht)) { const auto ret = cds_lfht_del(the_trigger_agents_ht_by_domain->ht, &agent->node.node); diff --git a/src/bin/lttng-sessiond/save.cpp b/src/bin/lttng-sessiond/save.cpp index 4eb600f4c..715325a4a 100644 --- a/src/bin/lttng-sessiond/save.cpp +++ b/src/bin/lttng-sessiond/save.cpp @@ -1181,8 +1181,8 @@ static int save_agent_events(struct config_writer *writer, struct agent *agent) goto end; } - for (auto *agent_event : - lttng::urcu::lfht_iteration_adapter(*agent->events->ht)) { ltt_ust_event fake_event;