[cfe-commits] [libcxx] r173172 - in /libcxx/trunk: include/locale src/string.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Tue Jan 22 13:18:41 PST 2013


On 22.01.2013, at 21:41, Howard Hinnant wrote:

> On Jan 22, 2013, at 3:22 PM, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> 
>> On Tue, Jan 22, 2013 at 05:26:09PM -0000, Howard Hinnant wrote:
>>> Author: hhinnant
>>> Date: Tue Jan 22 11:26:08 2013
>>> New Revision: 173172
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=173172&view=rev
>>> Log:
>>> Saleem Abdulrasool: If errno is defined as volatile int, the qualifier differences can cause
>>> template typename deductions on swap<> (used in string.cpp).
>> 
>> Why are you using swap<> in first place? errno is either an integer or
>> lvalue of int type and a plain assignment should be exactly what is
>> desired here?
>> 
>> Joerg
> 
> Hmmm..  just looking at float stof(const string& str, size_t* idx) as an example.  If I didn't use swap, I think this is how I would code it:
> 
> float
> stof(const string& str, size_t* idx)
> {
>    char* ptr;
>    const char* const p = str.c_str();
>    typename remove_reference<decltype(errno)>::type errno_save = errno;

I'm just slightly fuzzy on the auto deduction rules, but wouldn't

auto errno_save = errno;

have exactly the same effect?

Sebastian



More information about the cfe-commits mailing list