Build fix: workaround g++ 4.8 decltype handling bug
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2023 20:28:09 +0000 (16:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2023 20:33:30 +0000 (16:33 -0400)
commit69e98ad60c01ddfbfa6eb843960f77804173dd0f
tree7b16c2cdd075cf8003007d76d8de9b60639e8b98
parentf9a4135756da1947c2aa00e5b1e3c8e572d02107
Build fix: workaround g++ 4.8 decltype handling bug

g++ 4.8.5 fails to build with the following error:
  g++ -std=gnu++11 -DHAVE_CONFIG_H   -I../../../include -I../../../include -I../../../src -I../../../src -include config.h  -I/home/mjeanson/opt/include   -I/home/mjeanson/opt/include   -DINSTALL_BIN_PATH=\""/home/mjeanson/opt/bin"\"   -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-aliasing -Wall -Wextra -Wmissing-declarations -Wundef -Wredundant-decls -Wshadow -Wsuggest-attribute=format -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Wlogical-op -Winit-self -Wno-incomplete-setjmp-declaration -Wno-gnu-folding-constant -Wno-sign-compare -pthread  -Wno-shadow -Wno-missing-field-initializers -MT commands/lttng-list_triggers.o -MD -MP -MF commands/.deps/lttng-list_triggers.Tpo -c -o commands/lttng-list_triggers.o `test -f 'commands/list_triggers.cpp' || echo './'`commands/list_triggers.cpp
  In file included from commands/../utils.hpp:12:0,
                   from commands/../command.hpp:12,
                   from commands/list_triggers.cpp:8:
  ../../../src/common/container-wrapper.hpp: In instantiation of ‘typename std::conditional<std::is_pointer<_Dp>::value, ElementType, ElementType&>::type lttng::utils::random_access_container_wrapper<ContainerType, ElementType, ContainerOperations>::operator[](std::size_t) [with ContainerType = const lttng_action*; ElementType = const lttng_action*; ContainerOperations = lttng::ctl::details::const_action_list_operations; typename std::conditional<std::is_pointer<_Dp>::value, ElementType, ElementType&>::type = const lttng_action*; std::size_t = long unsigned int]’:
  ../../../src/common/container-wrapper.hpp:78:21:   required from ‘typename std::conditional<std::is_pointer<U>::value, IteratorElementType, IteratorElementType&>::type lttng::utils::random_access_container_wrapper<ContainerType, ElementType, ContainerOperations>::_iterator<IteratorContainerType, IteratorElementType>::operator*() const [with IteratorContainerType = lttng::utils::random_access_container_wrapper<const lttng_action*, const lttng_action*, lttng::ctl::details::const_action_list_operations>; IteratorElementType = const lttng_action*; ContainerType = const lttng_action*; ElementType = const lttng_action*; ContainerOperations = lttng::ctl::details::const_action_list_operations; typename std::conditional<std::is_pointer<U>::value, IteratorElementType, IteratorElementType&>::type = const lttng_action*]’
  commands/list_triggers.cpp:1030:66:   required from here
  ../../../src/common/container-wrapper.hpp:133:69: error: ‘const’ qualifiers cannot be applied to ‘lttng::utils::random_access_container_wrapper<const lttng_action*, const lttng_action*, lttng::ctl::details::const_action_list_operations>&’
   const auto& const_this = static_cast<const decltype(*this)&>(*this);
                                                                     ^

This bug was fixed in g++ 5.0, see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60420

In this case, we can simply restate the class' type to work around the
issue since the problem is confined to the handling of decltype
declaration specifiers.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3ba6b012af0f43f7cd06d780e6800c42e16cc66c
src/common/container-wrapper.hpp
This page took 0.025398 seconds and 4 git commands to generate.