Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: killerbot on January 31, 2006, 10:39:16 am

Title: istringstream : bug @ MS
Post by: killerbot 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:


Title: Re: istringstream : bug @ MS
Post by: mandrav on January 31, 2006, 10:59:49 am
Are you serious? Streaming to an integer fails?
LOL :lol:
Title: Re: istringstream : bug @ MS
Post by: killerbot on January 31, 2006, 11:02:50 am
damn right, at least from an istringstream.
Title: Re: istringstream : bug @ MS
Post by: AkiraDev 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"?  :?

Title: Re: istringstream : bug @ MS
Post by: sethjackson 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.
Title: Re: istringstream : bug @ MS
Post by: Game_Ender 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.
Title: Re: istringstream : bug @ MS
Post by: thomas 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...
Title: Re: istringstream : bug @ MS
Post by: 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.
Title: Re: istringstream : bug @ MS
Post by: AkiraDev 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.
Title: Re: istringstream : bug @ MS
Post by: thomas 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".
Title: Re: istringstream : bug @ MS
Post by: killerbot 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 ???
Title: Re: istringstream : bug @ MS
Post by: Game_Ender 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 (http://lab.msdn.microsoft.com/productfeedback/ViewWorkaround.aspx?FeedbackID=FDBK40119#1).  I am not sure if they have release any updates for VS 2005 that contain a better fix.
Title: Re: istringstream : bug @ MS
Post by: takeshimiya on January 31, 2006, 09:01:36 pm
If it's a bug in their STL implementation, just use STLPort (http://www.stlport.org/) (of course, that is, if you really like (or need) to use the M$ free compiler).
Title: Re: istringstream : bug @ MS
Post by: Michael 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

Title: Re: istringstream : bug @ MS
Post by: killerbot 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$
Title: Re: istringstream : bug @ MS
Post by: Game_Ender on February 01, 2006, 12:51:39 am
If it's a bug in their STL implementation, just use STLPort (http://www.stlport.org/) (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.
Title: Re: istringstream : bug @ MS
Post by: sethjackson 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:
Title: Re: istringstream : bug @ MS
Post by: Michael 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
Title: Re: istringstream : bug @ MS
Post by: Der Meister 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...)
Title: Re: istringstream : bug @ MS
Post by: Michael 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
Title: Re: istringstream : bug @ MS
Post by: takeshimiya on February 01, 2006, 02:31:36 pm
Suppose you really need to use MSVC.
The solution is easy:

Title: Re: istringstream : bug @ MS
Post by: killerbot 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 !!
Title: Re: istringstream : bug @ MS
Post by: David Perfors 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...