https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116969

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We could just drop the format attribute from the decl and then we don't need to
suppress a warning. The attribute isn't useful here, since we know the format
string is correct for the arguments we're using, and the compiler doesn't know.

So something like:

--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -637,10 +637,14 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11

 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
       && defined __LONG_DOUBLE_IEEE128__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat" // '%Lf' expects 'long double'
-extern "C"
-__typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 __asm__("snprintf");
+// The snprintf symbol in glibc that works with __ibm128 format is not visible
+// when compiling with -mabi=ieeelongdouble so we use this name for it
instead.
+// N.B. we don't use __typeof__(__builtin_snprintf) for the type because that
+// would inherit __attribute__((__format__(printf, 3, 4))) and then warn about
+// passing __ibm128 to %Lf instead of long double. The warning would be wrong
+// because long double in this TU is __ieee128 and snprintf expects __ibm128.
+extern "C" int
+__glibcxx_snprintfibm128(char*, size_t, const char*, ...) __asm__("snprintf");

   template<typename _CharT, typename _OutIter>
     _OutIter
@@ -673,7 +677,6 @@ __typeof__(__builtin_snprintf) __glibcxx_snprintfibm128
__asm__("snprintf");
       return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
                    : _M_insert<false>(__s, __io, __fill, __digits);
     }
-#pragma GCC diagnostic pop
 #endif

 _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11

Reply via email to