Re: [patch] Leave errno unchanged by successful std::stoi etc

2015-10-01 Thread Jonathan Wakely
commit 502928c8061343e82e982e06299c11d465f64b6c Author: Jonathan Wakely Date: Wed Sep 30 14:10:58 2015 +0100 Save-and-restore errno more carefully in libstdc++ * doc/xml/manual/diagnostics.xml: Document use of errno. * config/locale/generic/c_locale.cc (_Save_errno): New he

Re: [patch] Leave errno unchanged by successful std::stoi etc

2015-09-30 Thread Jonathan Wakely
On 29/09/15 10:50 -0600, Martin Sebor wrote: On 09/29/2015 10:15 AM, Jakub Jelinek wrote: On Tue, Sep 29, 2015 at 05:10:20PM +0100, Jonathan Wakely wrote: That looks wrong to me, you only restore errno if you don't throw :(. If you throw, then errno might remain 0, which is IMHO undesirable.

Re: [patch] Leave errno unchanged by successful std::stoi etc

2015-09-29 Thread Martin Sebor
On 09/29/2015 10:15 AM, Jakub Jelinek wrote: On Tue, Sep 29, 2015 at 05:10:20PM +0100, Jonathan Wakely wrote: That looks wrong to me, you only restore errno if you don't throw :(. If you throw, then errno might remain 0, which is IMHO undesirable. My thinking was that a failed conversion that

Re: [patch] Leave errno unchanged by successful std::stoi etc

2015-09-29 Thread Jakub Jelinek
On Tue, Sep 29, 2015 at 05:10:20PM +0100, Jonathan Wakely wrote: > >That looks wrong to me, you only restore errno if you don't throw :(. > >If you throw, then errno might remain 0, which is IMHO undesirable. > > My thinking was that a failed conversion that throws an exception > should be allowed

Re: [patch] Leave errno unchanged by successful std::stoi etc

2015-09-29 Thread Jonathan Wakely
On 29/09/15 17:25 +0200, Jakub Jelinek wrote: On Tue, Sep 29, 2015 at 04:15:41PM +0100, Jonathan Wakely wrote: We set errno=0 in __gnu_cxx::__stoa in order to reliably detect when it gets set to ERANGE. This restores the previous value when the conversion is successful. Tested powerpc64le-linux

Re: [patch] Leave errno unchanged by successful std::stoi etc

2015-09-29 Thread Jakub Jelinek
On Tue, Sep 29, 2015 at 04:15:41PM +0100, Jonathan Wakely wrote: > We set errno=0 in __gnu_cxx::__stoa in order to reliably detect when > it gets set to ERANGE. This restores the previous value when the > conversion is successful. > > Tested powerpc64le-linux, committed to trunk. > commit 412f75d

[patch] Leave errno unchanged by successful std::stoi etc

2015-09-29 Thread Jonathan Wakely
We set errno=0 in __gnu_cxx::__stoa in order to reliably detect when it gets set to ERANGE. This restores the previous value when the conversion is successful. Tested powerpc64le-linux, committed to trunk. commit 412f75dc37b1048e14996c9caafa46c00db8eb30 Author: Jonathan Wakely Date: Tue Sep 29