Fix: Compilation failure deducing type of `auto` variables in GCC 4.8
authorKienan Stewart <kstewart@efficios.com>
Tue, 6 Aug 2024 15:32:57 +0000 (11:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 22 Aug 2024 17:25:57 +0000 (13:25 -0400)
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_event,
                                           ^                                                                 save.cpp:1185:43: error: use of 'agent_event' before deduction of 'auto'
save.cpp:1185:43: error: use of 'agent_event' before deduction of 'auto'
save.cpp:1187:26: error: template argument 1 is invalid
        &agent_event::node>(*agent->events->ht)) {
                          ^
save.cpp:1187:26: error: creating pointer to member of non-class type '<type error>'
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 <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/agent.cpp
src/bin/lttng-sessiond/save.cpp

index ee93713e1b65092baad03285d9c5ed98b9661319..4be1c32fcbed7a7d32344ced3f306eee8686cfaa 100644 (file)
@@ -1544,8 +1544,8 @@ void agent_by_event_notifier_domain_ht_destroy()
                return;
        }
 
-       for (auto *agent :
-            lttng::urcu::lfht_iteration_adapter<agent, decltype(agent::node), &agent::node>(
+       for (struct agent *agent :
+            lttng::urcu::lfht_iteration_adapter<struct agent, decltype(agent::node), &agent::node>(
                     *the_trigger_agents_ht_by_domain->ht)) {
                const auto ret =
                        cds_lfht_del(the_trigger_agents_ht_by_domain->ht, &agent->node.node);
index 4eb600f4cfac803f84c5bad4e70ede6fca510104..715325a4a25ace439c0e698dc5a599f8173ed29e 100644 (file)
@@ -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_event,
+       for (struct agent_event *agent_event :
+            lttng::urcu::lfht_iteration_adapter<struct agent_event,
                                                 decltype(agent_event::node),
                                                 &agent_event::node>(*agent->events->ht)) {
                ltt_ust_event fake_event;
This page took 0.027847 seconds and 4 git commands to generate.