Re: Problem with reading an int with operator>>



"andreas fabri" <andreasfabri@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B3C8648E-DCDE-4731-B645-77AC49468B93@xxxxxxxxxxxxxxxx

"P.J. Plauger" wrote:

"andreas fabri" <andreasfabri@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1A1B4A26-081B-4E4E-9313-5D6B0938F233@xxxxxxxxxxxxxxxx

I can't read an int as follows
int n, m;
char c;
std::cin >> n >> c >> m;

if the two ints are separated by a comma.
The problem is that somethig seems to be
wrong with the locale which seems to interpret
the comma as thousandsep.


According to a posting by Plaugher in comp.lang.c++.moderated
with the subject locale and streams on VC8
http://groups.google.fr/group/comp.lang.c++.moderated/tree/browse_frm/month/2005-12/d2e8e290cf0a5f87?rnum=101&_done=%2Fgroup%2Fcomp.lang.c%2B%2B.moderated%2Fbrowse_frm%2Fmonth%2F2005-12%3F#doc_41cda4688cd1bbe0

this is a bug in VC8. Plaugher also proposes a fix, but
it didn't work for my example.

Probably because you're using the flawed version built into a DLL, not
the
changed version in the edited header file.

Is there a service pack for VC8 that solves this rather
fundamental problem.

I hear that one is in the works, but I don't know of any publicly
announced
release date.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com




Thanks for the reply.
Is there a workaround, so that I dont use the precompiled dll?
Can I recompile it (but what?) ?

I'm not sure that you can statically link at all these days. The only
trick I can think of, which is pretty unpalatable, is to make a
stream that doesn't look like istream<char, char_traits<char> >,
probably by writing your own traits class. That would outsmart
the prebuilt facets in the DLL. But that may well lead to other
surprises.

It might be worth to add the example program to a regression
test.

I'm sure that's been done.

It's almost unbelievable to have such a bug in VC8, or
the STL shipped with the compiler.

As I've explained before, the bug arose from the collision of
two "Friday afternoon edits" -- changes to the C++ Standard
that were made with no supporting committee resolutions.
Fixing one problem made the code vulnerable to the other.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


.



Relevant Pages


Loading