On Tue, 1 Oct 2024 at 08:05, Thomas Schwinge <[email protected]> wrote:
>
> Hi!
>
> When building powerpc64le-unknown-linux-gnu libstdc++-v3 with
> '--enable-werror', the build currently fails:
>
>     [...]
>     In file included from 
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.h:2071,
>                      from 
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/locale:45,
>                      from 
> [...]/libstdc++-v3/src/c++11/compatibility-ldbl-alt128.cc:26:
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:
>  In instantiation of ‘_OutIter std::__gnu_cxx11_ieee128::money_put<_CharT, 
> _OutIter>::__do_put(iter_type, bool, std::ios_base&, char_type, __ibm128) 
> const [with _CharT = char; _OutIter = std::ostreambuf_iterator<char, 
> std::char_traits<char> >; iter_type = std::ostreambuf_iterator<char, 
> std::char_traits<char> >; char_type = char]’:
>     [...]/libstdc++-v3/src/c++11/locale-inst-monetary.h:43:18:   required 
> from here
>        43 |   template class money_put<C, ostreambuf_iterator<C> >;
>           |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:658:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       658 |       int __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       659 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:665:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       665 |           __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       666 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:
>  In instantiation of ‘_OutIter std::__gnu_cxx11_ieee128::money_put<_CharT, 
> _OutIter>::__do_put(iter_type, bool, std::ios_base&, char_type, __ibm128) 
> const [with _CharT = wchar_t; _OutIter = std::ostreambuf_iterator<wchar_t, 
> std::char_traits<wchar_t> >; iter_type = std::ostreambuf_iterator<wchar_t, 
> std::char_traits<wchar_t> >; char_type = wchar_t]’:
>     [...]/libstdc++-v3/src/c++11/locale-inst-monetary.h:43:18:   required 
> from here
>        43 |   template class money_put<C, ostreambuf_iterator<C> >;
>           |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:658:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       658 |       int __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       659 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:665:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       665 |           __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       666 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     In file included from 
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/tr1/functional:42,
>                      from 
> [...]/libstdc++-v3/src/c++11/compatibility-ldbl-alt128.cc:222:
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/tr1/tuple:426:21: 
> error: ‘std::tr1::{anonymous}::ignore’ defined but not used 
> [-Werror=unused-variable]
>       426 |     _Swallow_assign ignore;
>           |                     ^~~~~~
>     cc1plus: all warnings being treated as errors
>     make[6]: *** [Makefile:1039: compatibility-ldbl-alt128.lo] Error 1
>     [...]
>     In file included from 
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.h:2071,
>                      from 
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/locale:45,
>                      from 
> [...]/libstdc++-v3/src/c++11/compatibility-ldbl-alt128-cxx11.cc:26:
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:
>  In instantiation of ‘_OutIter std::__gnu_cxx11_ieee128::money_put<_CharT, 
> _OutIter>::__do_put(iter_type, bool, std::ios_base&, char_type, __ibm128) 
> const [with _CharT = char; _OutIter = std::ostreambuf_iterator<char, 
> std::char_traits<char> >; iter_type = std::ostreambuf_iterator<char, 
> std::char_traits<char> >; char_type = char]’:
>     [...]/libstdc++-v3/src/c++11/locale-inst-monetary.h:43:18:   required 
> from here
>        43 |   template class money_put<C, ostreambuf_iterator<C> >;
>           |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:658:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       658 |       int __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       659 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:665:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       665 |           __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       666 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:
>  In instantiation of ‘_OutIter std::__gnu_cxx11_ieee128::money_put<_CharT, 
> _OutIter>::__do_put(iter_type, bool, std::ios_base&, char_type, __ibm128) 
> const [with _CharT = wchar_t; _OutIter = std::ostreambuf_iterator<wchar_t, 
> std::char_traits<wchar_t> >; iter_type = std::ostreambuf_iterator<wchar_t, 
> std::char_traits<wchar_t> >; char_type = wchar_t]’:
>     [...]/libstdc++-v3/src/c++11/locale-inst-monetary.h:43:18:   required 
> from here
>        43 |   template class money_put<C, ostreambuf_iterator<C> >;
>           |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:658:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       658 |       int __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       659 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     
> [...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/locale_facets_nonio.tcc:665:66:
>  error: format ‘%Lf’ expects argument of type ‘long double’, but argument 5 
> has type ‘__ibm128’ [-Werror=format=]
>       665 |           __len = __glibcxx_snprintfibm128(__cs, __cs_size, 
> "%.*Lf", 0,
>           |                                                              ~~~~^
>           |                                                                  |
>           |                                                                  
> long double
>       666 |                                              __units);
>           |                                              ~~~~~~~
>           |                                              |
>           |                                              __ibm128
>     cc1plus: all warnings being treated as errors
>     make[6]: *** [Makefile:1043: compatibility-ldbl-alt128-cxx11.lo] Error 1
>     make[6]: *** No rule to make target 
> '../src/c++98/libc++98convenience.la', needed by 'libstdc++.la'.
>     make[6]: *** No rule to make target 
> '../src/c++11/libc++11convenience.la', needed by 'libstdc++.la'.
>     make[6]: Target 'all-am' not remade because of errors.
>     make[6]: Leaving directory 
> '[...]/powerpc64le-unknown-linux-gnu/libstdc++-v3/src'
>     [...]
>
> Is the attached
> "WIP Mute '__ibm128' '-Wformat' diagnostics in 
> 'libstdc++-v3/include/bits/locale_facets_nonio.tcc'"
> the right way to address this?  (..., at least for the time being, until
> someone steps up to fix this properly -- I suppose?  CCing the
> "rs6000/powerpc port" maintainers.)

Yes, this is the right way to fix it, but please just use the pragmas
once for both cases, and trim the comment, like so:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat" // '%Lf' expects 'long double'
      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 328. Bad sprintf format modifier in money_put<>::do_put()
      int __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0,
                         __units);
      // If the buffer was not large enough, try again with the correct size.
      if (__len >= __cs_size)
    {
      __cs_size = __len + 1;
      __cs = static_cast<char*>(__builtin_alloca(__cs_size));
      __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0,
                         __units);
    }
#pragma GCC diagnostic pop

OK for trunk with that change, thanks.

Reply via email to