Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2004-05-16 04:09:25


Hi everybody,

as promised the dynamic_bitset tests are being _slowly_ settled. My
apologies for the very "calm" pace but that's all that my spare time
allows me. This morning I've fixed an error caused by VC6's Dinkum
Lib. Since the library in this case affects the dynamic_bitset
behavior I'd like to ask for you opinion. Try the following program,
which attempts to read a string from an *empty* file:

#include <iostream>
#include <ostream>
#include <fstream>
#include <string>

int main()
{
  using namespace std;

  ofstream of("a_temporary_file");
  of.close();

  ifstream f("a_temporary_file");
  string s = "help";
  f >> s;
  std::cout << "The string is now " << s << '\n';
  std::cout << "(length = " << s.length() << ")\n";
}

With VC6's library the string is erase()d. That's because the code in
the sentry constructor fails to set an error bit in the stream state
if the file is empty. With all other libraries at least eofbit is set
(according to lib issue 195 failbit should be set too but many
implementations deliberately avoid that; see for instance:
http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00086.html); thus
bool(sentry_object) is false and the string remains untouched. With
dynamic_bitset the situation is exactly the same, as the extractor
relies on the underlying library to construct a sentry. Now, the
question is: do you see any problems in this? Note that it means
attempting to extract a dynamic_bitset from an empty file clears the
bitset with VC6's Dinkum while leaves it unchanged on (all) other
implementations; however the behavior is consistent with extractions
of other types (std::strings) on each platform. Fixing the behavior at
the dynamic_bitset extractor level to make it consistent across
different standard libraries would be, I think, quite tricky (and
ugly).

Secondly, a help request. There are some MW errors which I won't be
able to fix, as I don't have access to that compiler:

http://boost.sourceforge.net/regression-logs/cs-win32_metacomm/output/bin-boost-libs-dynamic_bitset-dyn_bitset_unit_tests1-test-cwpro8-debug.html

If anyone wants to submit a patch I'd be more than happy to integrate
it.

Thanks,

Genny.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk