Re: [Boost-bugs] [Boost C++ Libraries] #8966: No exception thrown (e.g. std::bad_alloc) on allocation failure in lexical_cast

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8966: No exception thrown (e.g. std::bad_alloc) on allocation failure in lexical_cast
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-06 14:13:06


#8966: No exception thrown (e.g. std::bad_alloc) on allocation failure in
lexical_cast
---------------------------------------+--------------------------
  Reporter: Martin <martin.raiber@…> | Owner: apolukhin
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: lexical_cast
   Version: Boost Development Trunk | Severity: Cosmetic
Resolution: | Keywords:
---------------------------------------+--------------------------

Comment (by apolukhin):

 This is a very doubtful and unportable feature. According to C++11,
 setting `stream.exceptions(std::ios::badbit);` guarantees only that it
 throws `basic_ios::failure` in case of `badbit` error:

 ---

 `void clear(iostate state = goodbit);`

 Effects: If `((state | (rdbuf() ? goodbit : badbit)) & exceptions()) ==
 0`, returns. Otherwise,
 the function throws an object fail of class `basic_ios::failure`
 (27.5.3.1.1), constructed with
 implementation-defined argument values.

 `void setstate(iostate state);`

 Effects: Calls `clear(rdstate() | state)` (which may throw
 basic_ios::failure (27.5.3.1.1)).

 ---

 Applying fix from this ticket will break user code (users expecting and
 catching `bad_lexical_cast` exceptions) and result in less predictable
 behaviour.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8966#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC