News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

istringstream : bug @ MS

Started by killerbot, January 31, 2006, 10:39:16 AM

Previous topic - Next topic

killerbot

Very very off topic, in the case I did not do anything wrong, I have found a bug in M$ DevStudio 2005. And off course things work well in Code::Blocks  :lol: :lol: :lol: :lol:

#include <string>
#include <sstream>
#include <iostream>

using namespace std;

int main()
{
string FirstWord("267,45");
istringstream iss2(FirstWord);
int x = 0;
iss2 >> x; //<------------------------------ M$ goes wrong here
char Comma = 0;
iss2 >> Comma;
if(Comma != ',')
{
return -1;
}
int y = 0;
iss2 >> y;
cout << x << "," << y << endl;
} // end of main


The code above, fails to read in the integer value into x (.NET 2003 did it OK), the stream even goes in to 'fail' or 'bad' state, since later on even reading a char is no longer possible. (If you start with a char, then you would get the '2').

So, once more, in case I did not do anything wrong, beware of using M$, USE CB.
Excuse me , what did you say --> USE CB.  :twisted: :twisted:



mandrav

Are you serious? Streaming to an integer fails?
LOL :lol:
Be patient!
This bug will be fixed soon...

killerbot

damn right, at least from an istringstream.

AkiraDev

Good grief. How on Earth did this get past the Beta testing?
Is this "the most compliant compiler"?  :?


sethjackson

 :lol: :lol: :lol: That is M$ for you. Not to metion their IDE's are slow and bloated...... Needless to say C::B isn't bloated.  :D USE C::B.

Game_Ender

Why don't you just try this code in an un manually patched version of VS 2005 and any VS 2005 Express edition:
Code (cpp) Select

#include <sstream>

int main()
{
unsigned int x = 10000000;
while( x-- )
{
std::iostream s(0);
}
}


Then just watch the memory usage shoot sky high.  This literally makes the expression edition useless because you have to apply a patch manually and recompile the libraries to fix this in the full version.  The express edition doesn't come with the libraries.

thomas

That is probably deliberate behaviour.

Very likely, the entire purpose of the Express Edition is that everybody is fooled into saying "why, an IDE for free, that's great". By the time you discover that it is in fact unusable for anything but the most trivial stuff, you have to buy the full version, because that is cheaper than migrating to a different IDE...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Game_Ender

It might be deliberate that they are not releasing a patch, but the bug was not deliberate because if you bought VS 2005 you have to patch the library by hand and then recompile it.

AkiraDev

In any case, the only people who could spot the bug are at the knowledge level of professionals who would have chosen the complete suite. Not that they should be happy about recompiling the libraries.

thomas

Quote from: Game_Ender on January 31, 2006, 05:27:13 PM
It might be deliberate that they are not releasing a patch, but the bug was not deliberate because if you bought VS 2005 you have to patch the library by hand and then recompile it.
Oh, don't believe that this would prevent them for a second.

They also built a lot of security holes into Windows deliberately, only to thwart piracy and to further Internet Explorer without violating the warrants against them.

Without using Windows update, your computer is entirely useless. As soon as you connect it to the internet, it will cease to function within a few minutes.

Windows update, on the other hand, only works with Internet Explorer (you cannot even access the site if your user agent is anything else but IE5/6) and with "Windows genuine advantage validation".
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

killerbot

I use the MSDN full version.

@Game_ender : what's that stuff about manual patching VS 2005 ???

Game_Ender

If you have run the above code sample and task manager showed your memory usage growing continusouly then you can use the workaround described here: Microsoft Workaround.  I am not sure if they have release any updates for VS 2005 that contain a better fix.

takeshimiya

If it's a bug in their STL implementation, just use STLPort (of course, that is, if you really like (or need) to use the M$ free compiler).

Michael

Quote from: killerbot on January 31, 2006, 10:39:16 AM
#include <string>
#include <sstream>
#include <iostream>

using namespace std;

int main()
{
//string FirstWord("267,45");
string FirstWord("267 , 34"); //This works!!!
istringstream iss2(FirstWord);
int x = 0;
iss2 >> x; //<------------------------------ M$ goes wrong here
char Comma = 0;
iss2 >> Comma;
if(Comma != ',')
{
return -1;
}
int y = 0;
iss2 >> y;
cout << x << "," << y << endl;
} // end of main


Hello,

It seems that the problem is with the string. If you use string FirstWord("267 , 34");, it works.

Funny thing :D.

Michael

[url="http://img207.imageshack.us/img207/9728/411948picture4em.png"]http://img207.imageshack.us/img207/9728/411948picture4em.png[/url]

killerbot

yes then it works, and if you repalce the , by a . it also works. The string is not the poblem, the instringstream can't handle things right anymore, where it did in .NET 2003. Stupid M$