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

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
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: [Select]
#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: 4291
    • 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: 5193
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: C++
  1. #include <sstream>
  2.  
  3. int main()
  4. {
  5. unsigned int x = 10000000;
  6. while( x-- )
  7. {
  8. std::iostream s(0);
  9. }
  10. }

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: 5193
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.

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
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: [Select]
#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: 5193
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$

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: istringstream : bug @ MS
« Reply #15 on: February 01, 2006, 12:51:39 am »
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).


Thank you I should of thought of that myself.  The main reason I am toying with VS 2005 is because the when I using Code::Blocks with the VC 2003 toolkit the debugger keeps flaking out on me and I really need to finish my project.  So I need a slightly more reliable tool.

sethjackson

  • Guest
Re: istringstream : bug @ MS
« Reply #16 on: February 01, 2006, 03:12:55 am »
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$

Do you really need to be told that is not a bug but a feature (NOT).......  :lol: :lol: :lol:

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: istringstream : bug @ MS
« Reply #17 on: February 01, 2006, 11:46:01 am »
The string is not the poblem, the instringstream can't handle things right anymore, where it did in .NET 2003. Stupid M$

Did you try just with the Express Edition or with the other versions too (e.g., Professional)? May be it is just a problem related to the Express Edition.

Stupid M$

Agree :D.

Michael

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: istringstream : bug @ MS
« Reply #18 on: February 01, 2006, 11:50:54 am »
Here is the bug report for this issue:
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=724641c1-bfd9-4105-99b7-000e5024b64f

George Mileka's argument looks quite good and this was also the first thing that came to my mind. But it seems as we both were wrong and this is really a bug. Anyway, there is also a workaround given and they already fixed this bug - but it will only come with the next major release, whatever/whenever this will be...

And please do me a favor - stop this silly MS-blaming... Especially this one is a small bug that probably comes from a misunderstandig of the standard (and the standard is not always easy to understand - especially not in this case). Apart from this, Microsoft Visual Studio is still a very good IDE (in my opinion even the best one, sorry folks...)
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: istringstream : bug @ MS
« Reply #19 on: February 01, 2006, 12:06:36 pm »
And please do me a favor - stop this silly MS-blaming... Especially this one is a small bug that probably comes from a misunderstandig of the standard (and the standard is not always easy to understand - especially not in this case). Apart from this, Microsoft Visual Studio is still a very good IDE (in my opinion even the best one, sorry folks...)

Generally speaking, Visual Studio is a good IDE. I used it before C::B (and still use if requested in projects) and I felt relative comfortable with it. Regarding the bug and the misunderstanding of the standard I am not sure. M$ actively partipates to the C++ standardization process and C++ experts are working for M$. Moreover, M$ has not a good reputation, e.g., check for example with MPEG and MPEG-4. Anyway, this is just my opinion and not a beginning of a war :).

Michael

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: istringstream : bug @ MS
« Reply #20 on: February 01, 2006, 02:31:36 pm »
Suppose you really need to use MSVC.
The solution is easy:

  • Bug spotted in STL? Start using STLPort.
  • Bug spotted in the Compiler? Start using another Compiler.
  • Bug spotted in the IDE? Start using Code::Blocks. :)
  • Bug spotted in Code::Blocks? Send a bug report. :D
  • Fixed in SVN. :lol:

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: istringstream : bug @ MS
« Reply #21 on: February 01, 2006, 03:12:09 pm »
update : I got some feedback on my mail to M$. One solution is for the mentioned code to add the line : iss2.imbue(std::locale("C"));

                --> did not try that one, don't like to change sources, will try it though
The second work around told me to changec xclocnum and xlocmon, but that didn't help me (or I did something wrong), so waiting for the next M$ mail. Hey, they provided quick feedback !!

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: istringstream : bug @ MS
« Reply #22 on: February 01, 2006, 11:12:20 pm »
Hey, they provided quick feedback !!
I think they have nothing better todo :P they are tired of playing minesweeper...
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring