Title
Use of uncaught_exception()
Status
new
Section
[ostream.sentry]
Submitter
Roger Orr

Created on 2015-05-08.00:00:00, last changed 2019-03-21.18:51:56.

Messages

Date: 2019-03-21.18:51:56

Proposed resolution:

This wording is relative to N4810.

  1. Modify [ostream.sentry], class basic_ostream::sentry synopsis, as indicated:

    namespace std {
      template<class charT, class traits = char_traits<charT>>
      class basic_ostream<charT, traits>::sentry {
        bool ok_; // exposition only
        int uncaught_ = uncaught_exceptions(); // exposition only
      public:
        explicit sentry(basic_ostream<charT, traits>& os);
        ~sentry();
        explicit operator bool() const { return ok_; }
        sentry(const sentry&) = delete;
        sentry& operator=(const sentry&) = delete;
      };
    }
    

    […]

    ~sentry();
    

    -4- If (os.flags() & ios_base::unitbuf) && !uncaught_exceptions() <= uncaught_ && os.good() is true, calls os.rdbuf()->pubsync(). If that function returns -1, sets badbit in os.rdstate() without propagating an exception.

Date: 2019-03-15.00:00:00

[ 2019-03-21; Daniel comments and provides wording ]

The wording below implements Roger's suggestion.

Date: 2017-02-02.00:41:18

[ 2015-06, Telecon ]

JW: I already added an 's' here to make it use the new function, but that doesn't resolve Roger's suggestion to capture the value on entry and check it.

Date: 2015-05-08.00:00:00

In the current [ostream.sentry], p4 refers to the now deprecated std::uncaught_exception(): D.9 [depr.uncaught].

If ((os.flags() & ios_base::unitbuf) && !uncaught_exception() && os.good()) is true, calls os.rdbuf()->pubsync().

This needs to be changed, for example to use std::uncaught_exceptions() and to capture the value on entry and compare with the saved value on exit.

History
Date User Action Args
2019-03-21 18:51:56adminsetmessages: + msg10371
2019-03-21 18:51:56adminsetmessages: + msg10370
2015-09-27 20:30:23adminsetmessages: + msg7548
2015-05-08 00:00:00admincreate