I'm strongly against the option to resize the matrix since this will > there is general agreement, that it should not (or does not have to) I can > above pull-request does not, and Helmut also seems not to require it). > We still need to decide if the input operator shall resize the matrix (the > Chen-Pang made a pull-request on this feature here: Our own Howard Hinnant (who also happens to be libc++'s representative who invalidated the linked libc++ bug) suggests in answer to a duplicate of this question (as well as in the libc++ bug) that you use the workaround: is.(In reply to Christoph Hertzberg from comment #3) Libc++ proffers ios_base::badbit bit-wise ored with the desired ios_base::iostate as a workaround If badbit is on in exceptions(), the input function rethrows the exception without completing its actions, otherwise it does not throw anything and proceeds as if the called function had returned a failure indication. If one of these called functions throws an exception, then unless explicitly noted otherwise, the input function sets badbit in error state. There is a now invalidated bug against libc++ for this very issue. Libc++ invalidates bugs requesting it's mirroring of libstdc++ behavior ![]() Under libc++ no such exception is thrown, meaning the standard is upheld.Under libstdc++ an exception is still rethrown, which does not conform to the standard.If only the ios_base::failbit is set on a basic_istream::exceptions' mask and an event occurs, causing the ios_base::failbit to be set, such as extracting an invalid number as described above: The numeric, pointer, and boolean input overloads of basic_istream::operator> (technically, the overloads of num_get::get they call), if the input cannot be parsed as a valid value or if the value parsed does not fit in the destination type. The ios_base::failbit should be set on it's respective istream on events such as: Libstdc++ does not comply with this requirement but libc++ does If (exceptions()&badbit) != 0 then the exception is rethrown. If an exception is thrown during input then ios::badbit is turned on in *this’s error state. However for formatted input this is retrograded in 27.7.2.2.1 /1 requiring a throw to occur only when a bit-wise and of the mask and ios_base::badbit is non-zero: If it inserted no characters because it caught an exception thrown while extracting characters from *this and failbit is on in exceptions() (27.5.5.4), then the caught exception is rethrown. This is supported in 27.7.2.2.3 /15 for unformated insertion methods: The standard requires istreams to rethrow only when ios_base::badbit is set in basic_istream::exceptionsĬalling basic_istream::exceptions(istream::failbit) will set a mask which can be retrieved by calling basic_istream::exceptions() which according to 27.5.5.4 /11 of the standard is:Ī mask that determines what elements set in rdstate() cause exceptions to be thrown. If you find yourself there I would seriously consider the possibility of the is.exceptions(ios_base::failbit | ios_base::badbit) workaround. ![]() Wide usage of the istream could be combated by helper functions, but use of istream_iterators or compound overloads of the extraction operator quickly make the manual inspection of this an unreasonable task. What could make this a monumental task is the extent to which the istream is used. But honestly that only adds a bit of complexity. That'd need to look something like this: if((is.rdstate() & ios_base::failbit) != 0) throw ios_base::failure("basic_ios::clear") Īs noted by cpplearner you can't even use basic_istream::fail, you have to do a bit-wise test of the istream's rdstate return. ![]() If you're looking for a throw to happen only when ios_base::failbit is set and you need this to have the same behavior on libc++ and libstdc++ you'll have to check the ios_base::badbit after each input operation occurring on the istream. Unfortunately this workaround has the side effect of also rethrowing whenever ios_base::badbit is set independent of ios_base::failbit: libc++ proffers ios_base::badbit bit-wise ored with the desired ios_base::iostate as a workaround.libc++ invalidates bugs requesting it's mirroring of libstdc++ behavior.libstdc++ does not comply with this requirement but libc++ does.The standard requires istreams to rethrow only when ios_base::badbit is set in basic_istream::exceptions.First some background information (each of these is explained below under it's respective title if you would like further elaboration):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |