I have a testcase that is showing incorrect behavior ostrstream or
ostringstream:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <strstream>
#include <cmath>
void test1() {
std::ostringstream S;
long double x = std::pow(1e300,2);
S << "Something " << std::setprecision(8) << x;
S << " else";
std::printf("Test1: %s\n", S.str().c_str());
}
void test2() {
std::ostrstream S;
long double x = std::pow(1e300,2);
S << "Something " << std::setprecision(7) << x;
S << " else";
std::printf("Test2: %s\n", S.str());
}
void test3() {
std::ostrstream S;
long double x = 0.0/0.0;
S << "Something " << std::setprecision(8) << x;
S << " else";
std::printf("Test3: %s\n", S.str());
}
int main(int argc, char* argv[]) {
test1();
test2();
test3();
}
On solaris 8 with Sun Studio 8 patch 14 I get the following output
Test1: Something inf
Test2: Something inf else else
Test3: Something nan else
Test1 is missing else
Test2 has an extra else
Test3 looks ok.
On RedHat 3u6 I get the following output:
Test1: Something inf else
Test2: Something inf else
Test3: Something nan elseing inf else
Test1 and 2 look ok
Test3 however has extra output "ing inf else"
Any thoughts on this problem?
Thanks,
Jeremy
Jeremy Dean
Rogue Wave Software,
A QUOVADX(tm) division
Technical Support
Phone: 303-545-3205 -- 1-800-404-4767
E-mail: [EMAIL PROTECTED]
Web: http://www.roguewave.com/support
Knowledge Base entries:
http://www.roguewave.com/kbdocs/search.html
View issues online at:
http://www.roguewave.com/youraccount/login/