Issue Details (XML | Word | Printable)

Key: STDCXX-461
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Martin Sebor
Reporter: Jeremy Dean
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

Error in formatting of infinity

Created: 25/Jun/07 11:14 PM   Updated: 29/Jun/07 08:02 PM
Return to search
Component/s: 22. Localization
Affects Version/s: 4.1.3
Fix Version/s: 4.2.0

Time Tracking:
Not Specified

Resolved: 29/Jun/07 05:03 AM
Resolution Date: 29/Jun/07 05:03 AM


 Description  « Hide
referrenced in e-mail thread:
http://mail-archives.apache.org/mod_mbox/incubator-stdcxx-dev/200706.mbox/ajax/%3c46801DBC.90909@roguewave.com%3e

But the test program does demonstrate a real problem, and that is the formatting of infinity when the stream precision is greater than 7. It looks as though the num_put facet inserts the string "inf\0\0ity" into the stream rather than "inf".

$ cat u.cpp && make u && ./u | od -c
#include <cassert>
#include <iostream>
#include <sstream>

int main () {
std::ostringstream s;
s.precision (8);
s << 1 / 0.0;
std::cout << s.str () << '\n';
assert (s.str () == "inf");
}
gcc -c -I/build/sebor/stdcxx/include/ansi -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/build/sebor/stdcxx/include -I/build/sebor/stdcxx-gcc-4.1.0-11s/include
-I/build/sebor/stdcxx/examples/include -pedantic -nostdinc++ -g -W
-Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long u.cpp
u.cpp: In function 'int main()':
u.cpp:8: warning: division by zero in '1 / 0.'
gcc u.o -o u -L/build/sebor/stdcxx-gcc-4.1.0-11s/lib -lstd11s -lsupc++ -lm Assertion failed: s.str () == "inf", file u.cpp, line 10
0000000 i n f \0 \0 i t y \n
0000011



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #551735 Thu Jun 28 23:52:50 UTC 2007 sebor 2007-06-28 Martin Sebor <sebor@roguewave.com>

STDCXX-461
* num_put.cpp (__rw_fix_flt): Corrected the formatting of Infinities
and NaN's when precision exceeds the length of the formatted string.
Files Changed
MODIFY /incubator/stdcxx/trunk/src/num_put.cpp

Repository Revision Date User Message
ASF #551779 Fri Jun 29 03:10:25 UTC 2007 sebor 2007-06-28 Martin Sebor <sebor@roguewave.com>

* 22.locale.num.put.cpp (inf_nan_test): New function template
to exercise the formatting of infinities and, when enabled,
(quiet) NaNs, including STDCXX-461.
Files Changed
MODIFY /incubator/stdcxx/trunk/tests/localization/22.locale.num.put.cpp