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
{
}
+namespace lttng {
+namespace sessiond {
+namespace trace {
template <>
void lst::signed_enumeration_type::accept(type_visitor& visitor) const
{
{
visitor.visit(*this);
}
+} /* namespace trace */
+} /* namespace sessiond */
+} /* namespace lttng */
lst::array_type::array_type(unsigned int in_alignment, type::cuptr in_element_type) :
type(in_alignment), element_type{std::move(in_element_type)}
struct lttng_ht *token_to_event_notifier_rule_ht;
};
+namespace fmt {
template <>
-struct fmt::formatter<ust_app> : fmt::formatter<std::string> {
+struct formatter<ust_app> : formatter<std::string> {
template <typename FormatCtx>
typename FormatCtx::iterator format(const ust_app& app, FormatCtx& ctx)
{
- return fmt::format_to(ctx.out(),
+ return format_to(ctx.out(),
"{{ procname = `{}`, ppid = {}, pid = {}, uid = {}, gid = {}, version = {}.{}, registration time = {} }}",
app.name, app.ppid, app.pid, app.uid, app.gid, app.v_major,
app.v_minor,
lttng::utils::time_to_iso8601_str(app.registration_time));
}
};
-
+} /* namespace fmt */
#ifdef HAVE_LIBLTTNG_UST_CTL
} /* namespace sessiond */
} /* namespace lttng */
+namespace fmt {
template <>
-struct fmt::formatter<lttng::sessiond::ust::registry_event> : fmt::formatter<std::string> {
+struct formatter<lttng::sessiond::ust::registry_event> : formatter<std::string> {
template <typename FormatCtx>
typename FormatCtx::iterator format(
const lttng::sessiond::ust::registry_event& event, FormatCtx& ctx)
{
- return fmt::format_to(ctx.out(),
+ return format_to(ctx.out(),
"{{ name = `{}`, signature = `{}`, id = {}, session objd = {}, channel objd = {} }}",
event.name, event.signature, event.id, event.session_objd,
event.channel_objd);
}
};
+} /* namespace fmt */
#endif /* LTTNG_UST_REGISTRY_EVENT_H */
#include <vendor/fmt/core.h>
DIAGNOSTIC_POP
+namespace fmt {
template <>
-struct fmt::formatter<std::type_info> : fmt::formatter<std::string> {
+struct formatter<std::type_info> : formatter<std::string> {
template <typename FormatCtx>
typename FormatCtx::iterator format(const std::type_info& type_info, FormatCtx& ctx)
{
int status;
auto demangled_name = abi::__cxa_demangle(type_info.name(), nullptr, 0, &status);
- auto it = status == 0 ? fmt::formatter<std::string>::format(demangled_name, ctx) :
- fmt::formatter<std::string>::format(type_info.name(), ctx);
+ auto it = status == 0 ? formatter<std::string>::format(demangled_name, ctx) :
+ formatter<std::string>::format(type_info.name(), ctx);
free(demangled_name);
return it;
}
};
+} /* namespace fmt */
#endif /* LTTNG_FORMAT_H */