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 << val2;
        swprintf(largebuf, 512, L"%.*f", 3, val2);

The result should be:


However, whilst I get this result in os2.str (), in largebuf I get:


Has anyone seen this with other targets (it is from libstdc++-v3
regression program

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.


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