fmtlib: backport upstream fixes to suppress bogus gcc 13.1 warnings
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 6 Jun 2023 15:20:06 +0000 (11:20 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 6 Jun 2023 17:49:39 +0000 (13:49 -0400)
gcc 13.1 erroneously warns of dangling references when using our custom
formatters. This was reported to both fmtlib and gcc and fixes have been
provided, but are not released yet.

This change backports two fixes from the master branch to our vendored
version:
https://github.com/fmtlib/fmt/commit/f61f15cc5b11582d50d02ba0514c5344f7b2600e
https://github.com/fmtlib/fmt/commit/ef55d4f52ec527668a8e910a56ea79d9b939dbc2

For more information on the issue, see:
https://github.com/fmtlib/fmt/issues/3415
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=6b927b1297e66e26e62e722bf15c921dcbbd25b9

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I30bbbbe5e0aa2729e50228acdb528ee060d9df23

src/vendor/fmt/core.h

index bed8b40d3ee5513529d22c887c5bdf35121c3e97..2eff064cd363756bc63e5018fdc73f75da04f0a4 100644 (file)
@@ -1732,32 +1732,27 @@ constexpr auto encode_types() -> unsigned long long {
 
 template <typename Context, typename T>
 FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
-  const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
+  using arg_type = remove_cvref_t<decltype(arg_mapper<Context>().map(val))>;
 
   constexpr bool formattable_char =
-      !std::is_same<decltype(arg), const unformattable_char&>::value;
+          !std::is_same<arg_type, unformattable_char>::value;
   static_assert(formattable_char, "Mixing character types is disallowed.");
 
-  constexpr bool formattable_const =
-      !std::is_same<decltype(arg), const unformattable_const&>::value;
-  static_assert(formattable_const, "Cannot format a const argument.");
-
   // Formatting of arbitrary pointers is disallowed. If you want to output
   // a pointer cast it to "void *" or "const void *". In particular, this
   // forbids formatting of "[const] volatile char *" which is printed as bool
   // by iostreams.
   constexpr bool formattable_pointer =
-      !std::is_same<decltype(arg), const unformattable_pointer&>::value;
+    !std::is_same<arg_type, unformattable_pointer>::value;
   static_assert(formattable_pointer,
                 "Formatting of non-void pointers is disallowed.");
 
-  constexpr bool formattable =
-      !std::is_same<decltype(arg), const unformattable&>::value;
+  constexpr bool formattable = !std::is_same<arg_type, unformattable>::value;
   static_assert(
       formattable,
       "Cannot format an argument. To make type T formattable provide a "
       "formatter<T> specialization: https://fmt.dev/latest/api.html#udt");
-  return {arg};
+  return {arg_mapper<Context>().map(val)};
 }
 
 template <typename Context, typename T>
This page took 0.027396 seconds and 4 git commands to generate.