swprintf bug?
Jeremy Bennett
jeremy.bennett@embecosm.com
Thu Jun 16 16:05:00 GMT 2011
I have a problem with swprintf and fixed format output. The following
code in C++ should cause os2.str () and largebuf to end up with
identical contents:
double val2 = numeric_limits<double>::max();
wostringstream os2;
os2.precision(3);
os2.setf(wios::fixed);
os2 << val2;
swprintf(largebuf, 512, L"%.*f", 3, val2);
The result should be:
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000
However, whilst I get this result in os2.str (), in largebuf I get:
1797693134862315708145274237317043567980<junk>
Has anyone seen this with other targets (it is from libstdc++-v3
regression program
27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc)?
The problem occurred with the OpenRISC 1000 port of newlib (not part of
the standard distribution), which is a minimal implementation, offering
only standard output as a file stream. However this seems to be a
generic newlib problem, rather than something that is target dependent.
This is something I would normally report in Bugzilla, but I can't find
the newlib Bugzilla. If anyone can point me to it, that would be useful.
Any suggestions welcome.
Jeremy
--
Tel: +44 (1590) 610184
Cell: +44 (7970) 676050
SkypeID: jeremybennett
Email: jeremy.bennett@embecosm.com
Web: www.embecosm.com
More information about the Newlib
mailing list