[stlport-bugs] Fwd: Issues with the stlport library
Brought to you by:
complement
From: Chenyang <du...@gm...> - 2013-05-31 01:54:13
|
Hi Guys, Sorry for re- sending this message as it has been sent to the wrong maillist. An issue with the stlport library has been found. The string conversion to long long or short does not have the expected behavior. Below are two simple example programs: Simple 1, issue related to short: --------------------------------------------------------------------------------- The patch works fine for long long long/int but not for short. #include <iostream> #include <limits> #include <sstream> #include <string> using namespace std; int main(int argc, char **argv) { cout << "This is the upper bound of short " << std::numeric_limits<short>::max() << endl; cout << "Now if I try to convert le above value +1 which is 32768" << endl; std::stringstream ss("32768"); short result; ss >> result; cout << "It should fail..." << endl; if (ss.eof() && !ss.fail() && !ss.bad()) cout << " but it does not..." << result << endl; if (result == std::numeric_limits<short>::min()) cout << " And result is now min." << endl; return 0; } gives : This is the upper bound of short 32767 Now if I try to convert le above value +1 which is 32768 It should fail... but it does not...-32768 And result is now min. Simple 2, issue related to long long: --------------------------------------------------------------------------------- #include <iostream> #include <limits> #include <sstream> #include <string> using namespace std; int main(int argc, char **argv) { cout << "This is the upper bound of long long " << std::numeric_limits<long long>::max() << endl; cout << "Now if I try to convert the above value +1 which is 9223372036854775808" << endl; std::stringstream ss("9223372036854775808"); long long result; ss >> result; cout << "It should fail..." << endl; if (ss.eof() && !ss.fail() && !ss.bad()) cout << " but it does not..." << result << endl; if (result == std::numeric_limits<long long>::min()) cout << " And result is now min." << endl; return 0; } If you compile this and run it on the board, you get the following output: This is the upper bound of long long 9223372036854775807 Now if I try to convert the above value +1 which is 9223372036854775808 It should fail... but it does not...-9223372036854775808 And result is now min. This behaviour is wrong as the conversion ss>> result should fail. You may test this on your linux machine, the result is correct. You may also notice that I have some similar issue with long (instead of long long) Note that if you try to convert the max value +2, the conversion fails (looks like a off by one somewhere). -- Chenyang |