tags:

views:

44

answers:

3

hi Going thorugh overflow function documentation. I found overflow has following as return values.

Return Value:

A value different than EOF (or traits::eof() for other traits) signals success.

If the function fails, either EOF (or traits::eof() for other traits) is returned or an exception is thrown.

source :"http://www.cplusplus.com/reference/iostream/streambuf/overflow/"

Can anyone please tell me in which sceanrios is overflow function going to through an exception? Any help will be appreciated

A: 

Streambuf is abstraction for stream's underlying storage or communication channel. The overflow() function can fail for any reasons the storage or channel can fail. E.g. disk error for disk files, broken connection for sockets etc.

wilx
A: 

Although wilx detailed the fail (EOF) condition, the exception condition can be either one of these: http://www.aoc.nrao.edu/php/tjuerges/ALMA/STL/html-3.4.6/classstd_1_1exception.html (can you guess which one? :) -- but it should (obviously) be std::overflow_error if you're writing your own output stream or something.

David Titarenco
I don't think it is overflow_error because that exception is used for "Thrown to indicate arithmetic overflow.". I will try to put a check in the exception and see what is the exception type(I think it is std::ios_base::failure) . Thanks for help to you and wilx.
A: 

In my problematic scenario it was faling because it was not jumping the next address(setp calls was incrementating by 0) so retrying to use the same memory region and was giving segmentation fault.