Boost logo

Boost Users :

Subject: Re: [Boost-users] [xint] a bug in operator>> (was: Boost.XInt formal review)
From: Riccardo Murri (riccardo.murri_at_[hidden])
Date: 2011-03-11 19:19:02


Hello,

I wanted to do some testing of XInt for the review, so I thought I
could try it with a gaussian elimination code that I'm working on.

I only had a quick glance at the library; the documentation seems very
clear and my code compiled fine with Boost.XInt at the first attempt,
just by changing one typedef. I'd like to join Christofer Jefferson
in his praise of the work done for making XInt easy to use.

However, running it seemed to take forever. After a while I traced
this down to the following bug:

* a very simple I/O program that works with std integral types:

    $ cat a.cpp
    #include <iostream>

    int main(void)
    {
      int i;
      long x;
      while (not std::cin.eof()) {
        std::cin >> i >> x;
        std::cout << "Read i:" << i << ", x:" << x << std::endl;
        if (0 == i and 0 == x)
          break;
      };
      return 0;
    }

    $ c++ a.cpp -I ~/sw/include/

    $ ./a.out
    1 2
    Read i:1, x:2
    0 0
    Read i:0, x:0

* the same simple program fails and goes in a busy-loop cycle with
  XInt:

    $ cat a.cpp
    #include <iostream>
    #include <boost/xint/integer.hpp>

    int main(void)
    {
      int i;
      boost::xint::integer x;
      while (not std::cin.eof()) {
        std::cin >> i >> x;
        std::cout << "Read i:" << i << ", x:" << x << std::endl;
        if (0 == i and 0 == x)
          break;
      };
      return 0;
    }

    $ c++ a.cpp -I ~/sw/include/

    $ ./a.out
    1 2
    Read i:1, x:0
    Read i:1, x:0
    Read i:1, x:0
      <repeats ad libitum in a busy loop>

For the record, I've tried gcc 4.4.3 on Ubuntu 10.04, with Boost
1.45.0 plus XInt (from the .zip file).

Unofrtunately, this prevented all my computational jobs from getting
to do any number crunching (they have been stalled into the read cycle
for hours before I noticed).

I would like to see XInt accepted based on its simplicity of use, but
in the event I really did not test anything in the library except compilation.

Best regards,
Riccardo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net