You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All our reads via stream.read(...) are unchecked. That is, in case of extraction failures or premature eof, we silently go on with uninitialized data structures (hint: undefined behavior anyone?).
Note: ticket explains for read, same applies to write.
Two solutions are possible:
check the read function's return value (stream&) via its operator bool conversion
let streams throw on error (not on per default, to mock with developers)
Discussion: I think we can automate this to a certain degree with a clever substitution to turn
x.read(y,z);
into
ensure(x.read(y,z));
relying on the returned stream's conversion to bool in a boolean context, with ensure being a assert-like function that also triggers in release builds and potentially throws.
daniel-j-h
changed the title
std::basic_istream::read may fail, we do not check for this
read() and write() may fail, we do not check for this
Feb 26, 2016
All our reads via
stream.read(...)
are unchecked. That is, in case of extraction failures or premature eof, we silently go on with uninitialized data structures (hint: undefined behavior anyone?).Note: ticket explains for
read
, same applies towrite
.Two solutions are possible:
operator bool
conversionDiscussion: I think we can automate this to a certain degree with a clever substitution to turn
into
relying on the returned stream's conversion to bool in a boolean context, with
ensure
being a assert-like function that also triggers in release builds and potentially throws.References:
The text was updated successfully, but these errors were encountered: