public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114862] New: std::uppercase not applying to nan's and inf's
@ 2024-04-26  7:43 lcarreon at bigpond dot net.au
  2024-04-26  8:47 ` [Bug libstdc++/114862] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: lcarreon at bigpond dot net.au @ 2024-04-26  7:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114862
           Summary: std::uppercase not applying to nan's and inf's
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lcarreon at bigpond dot net.au
  Target Milestone: ---

The following code:

#include <limits>
#include <iostream>
#include <iomanip>

int main()
{
  double values[] =
  {
    std::numeric_limits<double>::quiet_NaN(),
    -std::numeric_limits<double>::quiet_NaN(),
    std::numeric_limits<double>::signaling_NaN(),
    -std::numeric_limits<double>::signaling_NaN(),
    std::numeric_limits<double>::infinity(),
    -std::numeric_limits<double>::infinity()
  };

  for (const auto& value : values)
  {
    std::cout
      << std::uppercase
      << std::fixed << std::setw(17) << std::left << value
      << "  "
      << std::fixed << std::setw(10) << std::left << std::setprecision(0) <<
value
      << "  "
      << std::fixed << std::setw(15) << std::left << std::setprecision(4) <<
value
      << "  "
      << std::fixed << std::setw(17) << std::left << std::setprecision(6) <<
value
      << std::endl;
  }

  return 0;
}

Generates the following output:

nan                nan         nan              nan
-nan               -nan        -nan             -nan
nan                nan         nan              nan
-nan               -nan        -nan             -nan
inf                inf         inf              inf
-inf               -inf        -inf             -inf

Which in my opinion is incorrect because it is not applying std::uppercase.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114862] std::uppercase not applying to nan's and inf's
  2024-04-26  7:43 [Bug libstdc++/114862] New: std::uppercase not applying to nan's and inf's lcarreon at bigpond dot net.au
@ 2024-04-26  8:47 ` redi at gcc dot gnu.org
  2024-04-26  9:02 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-26  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-26
             Status|UNCONFIRMED                 |NEW

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114862] std::uppercase not applying to nan's and inf's
  2024-04-26  7:43 [Bug libstdc++/114862] New: std::uppercase not applying to nan's and inf's lcarreon at bigpond dot net.au
  2024-04-26  8:47 ` [Bug libstdc++/114862] " redi at gcc dot gnu.org
@ 2024-04-26  9:02 ` redi at gcc dot gnu.org
  2024-04-26 11:48 ` redi at gcc dot gnu.org
  2024-04-30 22:02 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-26  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Actually I think we're doing exactly what the standard requires:

    ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
    ...
    // [22.2.2.2.2] Table 58
    if (__fltfield == ios_base::fixed)
      *__fptr++ = 'f';


when (flags & ios_base::floatfield) == ios_base::fixed the conversion specifier
is %f and uppercase is not considered. There is no way to use a conversion
specifier of %F with std::num_put. That seems odd, but it's what the standard
says.

Libc++ does what you expect, which seems to be non-conforming.

I don't see any library issues about this, so I'll talk to the committee.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114862] std::uppercase not applying to nan's and inf's
  2024-04-26  7:43 [Bug libstdc++/114862] New: std::uppercase not applying to nan's and inf's lcarreon at bigpond dot net.au
  2024-04-26  8:47 ` [Bug libstdc++/114862] " redi at gcc dot gnu.org
  2024-04-26  9:02 ` redi at gcc dot gnu.org
@ 2024-04-26 11:48 ` redi at gcc dot gnu.org
  2024-04-30 22:02 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-26 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Libc++ has tests for "INF" (although only for long double, not float or
double), so it's apparently not accidental. The relevant code is:

  if (floatfield == ios_base::fixed) {
    if (uppercase)
      *__fmtp = 'F';
    else
      *__fmtp = 'f';

That's been there since the initial commit in 2010.

MSVC behaves the same as libstdc++.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114862] std::uppercase not applying to nan's and inf's
  2024-04-26  7:43 [Bug libstdc++/114862] New: std::uppercase not applying to nan's and inf's lcarreon at bigpond dot net.au
                   ` (2 preceding siblings ...)
  2024-04-26 11:48 ` redi at gcc dot gnu.org
@ 2024-04-30 22:02 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-30 22:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've opened https://cplusplus.github.io/LWG/issue4084

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-30 22:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26  7:43 [Bug libstdc++/114862] New: std::uppercase not applying to nan's and inf's lcarreon at bigpond dot net.au
2024-04-26  8:47 ` [Bug libstdc++/114862] " redi at gcc dot gnu.org
2024-04-26  9:02 ` redi at gcc dot gnu.org
2024-04-26 11:48 ` redi at gcc dot gnu.org
2024-04-30 22:02 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).