C++ wrapper iostream input bug
Helmut Jarausch
jarausch at igpm.rwth-aachen.de
Mon Mar 22 17:52:18 CET 2010
Hi,
this is probably a long standing bug since I've encountered it with
several versions of gmp including 5.0.1
The 'operator>>' in the C++ wrapper library fails if the input
is not terminated by white space - see the example.
This doesn't fail for the input operator in general, just for
gmpxx.
gmp/gmpxx has been compiled with -O2 on different systems
and different versions of gcc/gmp.
This occurs with g++-4.4.3 but with older versions of g++, as well.
The failing example:
#include <iostream>
#include <sstream>
#include <gmpxx.h>
typedef mpz_class LONG;
int main() {
LONG X;
std::istringstream Inp("A9FB57DB"); // works OK if there is a trailing blank
Inp.exceptions(std::ios::failbit);
Inp >> std::hex >> X;
/* terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_ios::clear
*/
std::cout << X << std::endl;
}
This code should be working just fine.
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
More information about the gmp-bugs
mailing list