Build fix: specialization of template in different namespace
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 15 Jun 2022 19:09:03 +0000 (15:09 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 17 Jun 2022 14:56:35 +0000 (10:56 -0400)
commite2c2bec23d72b09ef5778dff54fa6ca4a34587bf
treebe0ac5b73c3c470bc76f0f2dda7de048fabee0f1
parent65cd3c0cfa205aa6f67ff974f561882d5eafdd89
Build fix: specialization of template in different namespace

Observed issue
==============

On older g++, such as gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413:

make[3]: Entering directory '/tmp/virtenv/src/lttng-tools/src/bin/lttng-sessiond'
  CXX      utils.lo
In file included from ust-app.hpp:15:0,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/common/format.hpp:17:24: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
 DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES
                        ^
In file included from ust-app.hpp:15:0,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/common/format.hpp:23:13: error: specialization of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' in different namespace [-fpermissive]
 struct fmt::formatter<std::type_info> : fmt::formatter<std::string> {
             ^
In file included from ../../../src/common/format.hpp:19:0,
                 from ust-app.hpp:15,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/vendor/fmt/core.h:707:8: error:   from definition of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' [-fpermissive]
 struct formatter {
        ^
In file included from ust-registry.hpp:20:0,
                 from ust-app.hpp:19,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
ust-registry-event.hpp:66:13: error: specialization of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' in different namespace [-fpermissive]
 struct fmt::formatter<lttng::sessiond::ust::registry_event> : fmt::formatter<std::string> {
             ^
In file included from ../../../src/common/format.hpp:19:0,
                 from ust-app.hpp:15,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/vendor/fmt/core.h:707:8: error:   from definition of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' [-fpermissive]
 struct formatter {
        ^
In file included from ust-app.hpp:19:0,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
ust-registry.hpp: In constructor 'lttng::sessiond::ust::registry_typed_enum<MappingIntegerType>::registry_typed_enum(const char*, const lttng_ust_ctl_enum_entry*, size_t)':
ust-registry.hpp:111:45: error: 'lttng::sessiond::trace::integer_type::signedness' is not a class, namespace, or enumeration
       lttng::sessiond::trace::integer_type::signedness::SIGNED :
                                             ^
ust-registry.hpp:112:51: error: 'lttng::sessiond::trace::integer_type::signedness' is not a class, namespace, or enumeration
             lttng::sessiond::trace::integer_type::signedness::UNSIGNED),
                                                   ^
In file included from lttng-sessiond.hpp:22:0,
                 from utils.cpp:17:
ust-app.hpp: At global scope:
ust-app.hpp:330:13: error: specialization of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' in different namespace [-fpermissive]
 struct fmt::formatter<ust_app> : fmt::formatter<std::string> {
             ^
In file included from ../../../src/common/format.hpp:19:0,
                 from ust-app.hpp:15,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/vendor/fmt/core.h:707:8: error:   from definition of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' [-fpermissive]
 struct formatter {
        ^
cc1plus: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1plus: warning: unrecognized command line option '-Wno-incomplete-setjmp-declaration'
Makefile:855: recipe for target 'utils.lo' failed
make[3]: *** [utils.lo] Error 1

This also applies to the following specializations:
  void lst::signed_enumeration_type::accept(type_visitor& visitor) const
  void lst::unsigned_enumeration_type::accept(type_visitor& visitor) const

Problem
=======

This is due to a now-fixed gcc bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Solution
========

Put the template specializations inside the proper namespace.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6b931065b37e6e9ba97f87c754c15808506c2ba8
src/bin/lttng-sessiond/field.cpp
src/bin/lttng-sessiond/ust-app.hpp
src/bin/lttng-sessiond/ust-registry-event.hpp
src/common/format.hpp
This page took 0.02565 seconds and 4 git commands to generate.