From 69e98ad60c01ddfbfa6eb843960f77804173dd0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 9 Jun 2023 16:28:09 -0400 Subject: [PATCH] Build fix: workaround g++ 4.8 decltype handling bug MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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::value, ElementType, ElementType&>::type lttng::utils::random_access_container_wrapper::operator[](std::size_t) [with ContainerType = const lttng_action*; ElementType = const lttng_action*; ContainerOperations = lttng::ctl::details::const_action_list_operations; typename std::conditional::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::value, IteratorElementType, IteratorElementType&>::type lttng::utils::random_access_container_wrapper::_iterator::operator*() const [with IteratorContainerType = lttng::utils::random_access_container_wrapper; IteratorElementType = const lttng_action*; ContainerType = const lttng_action*; ElementType = const lttng_action*; ContainerOperations = lttng::ctl::details::const_action_list_operations; typename std::conditional::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 auto& const_this = static_cast(*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 Change-Id: I3ba6b012af0f43f7cd06d780e6800c42e16cc66c --- src/common/container-wrapper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/container-wrapper.hpp b/src/common/container-wrapper.hpp index 0ed96d44a..7f9678d08 100644 --- a/src/common/container-wrapper.hpp +++ b/src/common/container-wrapper.hpp @@ -130,7 +130,7 @@ public: * * For more information, see Item 3 of Effective C++. */ - const auto& const_this = static_cast(*this); + const auto& const_this = static_cast(*this); /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) */ return const_cast::value, -- 2.34.1