rzarzynski: question about need_dynamic stuff in dout.h? see https://paste.centos.org/view/e8c376ec.
full log at https://kojipkgs.fedoraproject.org//work/tasks/2255/81372255/build.log
The following sippet is available on goldbot.org.
#include <iostream>
#include <utility>
namespace ceph::dout {
template<typename T>
struct dynamic_marker_t {
T value;
operator T() const { return value; }
};
template<typename T>
dynamic_marker_t<T> need_dynamic(T&& t) {
return dynamic_marker_t<T>{ std::forward<T>(t) };
}
template<typename T>
struct is_dynamic : public std::false_type {};
template<typename T>
struct is_dynamic<dynamic_marker_t<T>> : public std::true_type {};
} // ceph::dout
#define dout_impl(cct, sub, v) \
do { \
const bool dyn_or_stat = [&](const auto cctX) { \
if constexpr (ceph::dout::is_dynamic<decltype(sub)>::value || \
ceph::dout::is_dynamic<decltype(v)>::value) { \
return true; \
} else { \
/* The parentheses are **essential** because commas in angle \
* brackets are NOT ignored on macro expansion! A language's \
* limitation, sorry. */ \
return false; \
} \
}(cct); \
\
if (true) { \
std::cout << (dyn_or_stat ? "dynamic " : "static ")
#define dendl_impl std::endl; \
} \
} while (0)
#define ldpp_dout(dpp, v) \
if (decltype(auto) pdpp = (dpp); pdpp) /* workaround -Wnonnull-compare for 'this' */ \
dout_impl(nullptr, ceph::dout::need_dynamic(42), v)
int main (void)
{
ldpp_dout(42, 20) << "OK!" << dendl_impl;
}
It is unkwnown whether the following patch fixes the issue or not. Unfortunately, an environment with GCC-12 onboard isn't easily available yet.
Under x86-64 gcc (trunk)
on goldbot.org the problem does not replicate.
diff --git a/src/common/dout.h b/src/common/dout.h
index 421222d535f..3a76a842704 100644
--- a/src/common/dout.h
+++ b/src/common/dout.h
@@ -99,11 +99,14 @@ namespace ceph::dout {
template<typename T>
struct dynamic_marker_t {
T value;
- operator T() const { return value; }
+ // constexpr ctor isn't needed as it's an aggregate type
+ constexpr operator T() const { return value; }
};
template<typename T>
-dynamic_marker_t<T> need_dynamic(T&& t) {
+constexpr dynamic_marker_t<T> need_dynamic(T&& t) {
+ // deprecated in C++17 but that's fine for testing
+ static_assert(std::is_literal_type_v<T>);
+ static_assert(std::is_literal_type_v<dynamic_marker_t<T>>);
return dynamic_marker_t<T>{ std::forward<T>(t) };
}
Archiving the links: