Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-880

num_put::put(..., 1.0e+4932L, ...) formats "inf"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 4.2.1
    • 22. Localization
    • None
    • Regression
    • Incorrect Behavior

    Description

      The 22.locale.num.put.cpp fails 4 assertions with the head of trunk (see below). The test passes at 100% with 4.2.0. I reduced the failures to the following test case:

      $ cat t.cpp && gmake t && ./t 
      #include <cassert>
      #include <cstdio>
      #include <math.h>
      #include <sstream>
      
      int main ()
      {
          const long double x = 1.0e+4932L;
          assert (isnormal (x));
      
          std::ostringstream strm;
          strm << x;
      
          char buf [40];
          std::sprintf (buf, "%Lg", x);
      
          if (strm.str () == buf)
              return 0;
      
          std::printf ("%s != %s\n", strm.str ().c_str (), buf);
      
          assert (0);
      }
      aCC -c  -D_RWSTDDEBUG   -mt -I/amd/devco/sebor/stdcxx-4.2.x/include -I/build/seb
      or/stdcxx-4.2.x-aCC-6.16-15D//include -I/amd/devco/sebor/stdcxx-4.2.x/tests/incl
      ude  -AA  -g +d  +DD64 +w +W392,655,684,818,819,849 +W2193,2236,2261,2340,2401,2
      487 +W4227,4229,4231,4235,4237,4249 +W4255,4272,4284,4285,4286,4296,4297 +W3348 
        t.cpp
      "/amd/devco/sebor/stdcxx-4.2.x/include/loc/_ctype.h", line 545: warning #2186-D:
       
                pointless comparison of unsigned integer with zero
            if (   0 <= __c
                     ^
      
      "/amd/devco/sebor/stdcxx-4.2.x/include/loc/_ctype.h", line 555: warning #2186-D:
       
                pointless comparison of unsigned integer with zero
            if (   0 <= __c
                     ^
      
      aCC t.o -o t -L/build/sebor/stdcxx-4.2.x-aCC-6.16-15D//rwtest -lrwtest15D -AA +n
      ostl -Wl,+s   -mt +DD64 -L/build/sebor/stdcxx-4.2.x-aCC-6.16-15D//lib  -Wl,+b/bu
      ild/sebor/stdcxx-4.2.x-aCC-6.16-15D//lib:/build/sebor/stdcxx-4.2.x-aCC-6.16-15D/
      /rwtest -lstd15D  -lm 
      inf != 1e+4932
      Assertion failed: 0, file t.cpp, line 22
      ABORT instruction (core dumped)
      

      The output of 22.locale.num.put follows:

      $ ./22.locale.num.put -q
      # ASSERTION (S7) (4 lines):
      # TEXT: line 377: num_put<char>::put (..., long double = 1.18973e+4932) wrote "inf", expected "1.18973149535723176508575932662800702e+4932", flags = fmtflags(0), precision = 36
      # CLAUSE: lib.locale.num.put
      # LINE: 1854
      
      # ASSERTION (S7) (4 lines):
      # TEXT: line 377: num_put<char>::put (..., long double = 1e+4932) wrote "inf", expected { "1", '0' <repeats 34 times>, "1", '0' <repeats 4897 times> }, flags = fixed, precision = 0
      # CLAUSE: lib.locale.num.put
      # LINE: 1958
      
      # ASSERTION (S7) (4 lines):
      # TEXT: line 377: num_put<wchar_t>::put (..., long double = 1.18973e+4932) wrote L"inf", expected "1.18973149535723176508575932662800702e+4932", flags = fmtflags(0), precision = 36
      # CLAUSE: lib.locale.num.put
      # LINE: 1854
      
      # ASSERTION (S7) (4 lines):
      # TEXT: line 377: num_put<wchar_t>::put (..., long double = 1e+4932) wrote L"inf", expected { "1", '0' <repeats 34 times>, "1", '0' <repeats 4897 times> }, flags = fixed, precision = 0
      # CLAUSE: lib.locale.num.put
      # LINE: 1958
      
      # +-----------------------+----------+----------+----------+
      # | DIAGNOSTIC            |  ACTIVE  |   TOTAL  | INACTIVE |
      # +-----------------------+----------+----------+----------+
      # | (S1) INFO             |       96 |       96 |       0% |
      # | (S2) NOTE             |        1 |        1 |       0% |
      # | (S5) WARNING          |        2 |        2 |       0% |
      # | (S7) ASSERTION        |        4 |     1671 |      99% |
      # +-----------------------+----------+----------+----------+
      

      Attachments

        1. num_put.cpp.diff
          5 kB
          Farid Zaripov

        Activity

          People

            farid Farid Zaripov
            sebor Martin Sebor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Time Spent - 1h Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - 1h Remaining Estimate - 1h
                1h