[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test
From: |
Greg Chicares |
Subject: |
Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test |
Date: |
Sat, 7 Jan 2017 13:08:55 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.5.1 |
On 2017-01-06 22:53, Vadim Zeitlin wrote:
[...]
> The last two warnings show that the compiler selects to use e_direct
> specialization of value_cast_chooser and this means that
> value_cast_choice::convertible is true, which is indeed the case because
> the type of the literal "1" in the unit test, i.e. "char*" is convertible
> to bool via the unfortunate inherited from C pointer-to-zero-or-not
> conversion.
[...]
> The simplest fix I can propose is just testing for !is_array<>
"char*" is a pointer...and testing that it's not an array fixes this?
I'm confused. If the problem is that "char*" is a pointer, then why
wouldn't the fix need to test is_pointer<>? Or, if testing is_array<>
is the fix, then is a literal "1" actually an array, not a pointer?
I thought this:
char* p = "1";
defined a pointer to char (named 'p') and an (unnamed) array of
char containing the two elements '1' and '\0'. When we pass the
literal "1" to value_cast()...
- is it an array? (which it shouldn't convert to bool)
- or is it a pointer? (which should elude any is_array<> fix)?
- [lmi] [PATCH] Fix value_cast defect shown by the unit test, Vadim Zeitlin, 2017/01/06
- Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test,
Greg Chicares <=
- Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test, Greg Chicares, 2017/01/08
- Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test, Vadim Zeitlin, 2017/01/08
- Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test, Greg Chicares, 2017/01/09
- Re: [lmi] [PATCH] Fix value_cast defect shown by the unit test, Vadim Zeitlin, 2017/01/09
- [lmi] icedove anomaly, Greg Chicares, 2017/01/09
- [lmi] Replacing boost with std C++11 [Was: Fix value_cast defect shown by the unit test], Greg Chicares, 2017/01/09
- Re: [lmi] Replacing boost with std C++11 [Was: Fix value_cast defect shown by the unit test], Vadim Zeitlin, 2017/01/09
- [lmi] C++ modernization [Was: Replacing boost with std C++11], Greg Chicares, 2017/01/09
- Re: [lmi] C++ modernization [Was: Replacing boost with std C++11], Greg Chicares, 2017/01/10