
Jonathan Wakely wrote:
Rupert Kittinger wrote:
In the tuple_io.hpp header, there seems to be a slight problem in extract_and_check_delimiter(). The following snippet is problematic:
char c; if (is_delimiter) { is >> c; if (c!=d) { is.setstate(std::ios::failbit); } }
If c cannot be read because is.eof(), the result of c!=d is undefined.
IMHO the fix is neater as:
if (is>>c && c!=d)
basic_ios::operator void*() exists to support this syntax rather than explicitly testing the state with good(), fail() etc.
jon
Using is.good() is consistent with the rest of the file. Another fine point that is not visible from the context diff is that the code works as expected, because the only visible effect of the function is the change in stream state. If is >> c failed because of is.eof(), the failbit is already set, so it is irrelevant whether the if block is executed. But I get false positives from valgrind in my unit tests, and in this kind of code, the stack trace looks somewhat confusing :-) cheers, Rupert -- Rupert Kittinger <rkit@mur.at>