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)
commit93afa33ce85dc4672d8a77c3279060b86a6b0e16
tree00bf7618f4b1b3ec45aab9d4331e5f5b295ce686
parent34d5e96c19bc65e3f9ab518bc4fce5c24c5b64ca
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_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
This page took 0.02512 seconds and 4 git commands to generate.