Author Topic: istringstream : bug @ MS  (Read 16336 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
istringstream : bug @ MS
« on: January 31, 2006, 10:39:16 am »
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:

Code
#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:



Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: istringstream : bug @ MS
« Reply #1 on: January 31, 2006, 10:59:49 am »
Are you serious? Streaming to an integer fails?
LOL :lol:
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: istringstream : bug @ MS
« Reply #2 on: January 31, 2006, 11:02:50 am »
damn right, at least from an istringstream.

Offline AkiraDev

  • Multiple posting newcomer
  • *
  • Posts: 71
Re: istringstream : bug @ MS
« Reply #3 on: January 31, 2006, 12:06:27 pm »
Good grief. How on Earth did this get past the Beta testing?
Is this "the most compliant compiler"?  :?


sethjackson

  • Guest
Re: istringstream : bug @ MS
« Reply #4 on: January 31, 2006, 02:02:00 pm »
 :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.

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: istringstream : bug @ MS
« Reply #5 on: January 31, 2006, 05:00:43 pm »
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
#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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: istringstream : bug @ MS
« Reply #6 on: January 31, 2006, 05:22:35 pm »
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."

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: istringstream : bug @ MS
« Reply #7 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.

Offline AkiraDev

  • Multiple posting newcomer
  • *
  • Posts: 71
Re: istringstream : bug @ MS
« Reply #8 on: January 31, 2006, 05:34:03 pm »
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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: istringstream : bug @ MS
« Reply #9 on: January 31, 2006, 05:37:41 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."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: istringstream : bug @ MS
« Reply #10 on: January 31, 2006, 05:59:19 pm »
I use the MSDN full version.

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

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: istringstream : bug @ MS
« Reply #11 on: January 31, 2006, 06:13:36 pm »
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

  • Guest
Re: istringstream : bug @ MS
« Reply #12 on: January 31, 2006, 09:01:36 pm »
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).

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: istringstream : bug @ MS
« Reply #13 on: January 31, 2006, 09:06:27 pm »
Code
#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


Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: istringstream : bug @ MS
« Reply #14 on: January 31, 2006, 10:23:36 pm »
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$