lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] bourn_cast_test with MSVC (was: Don't initialize constexpr var


From: Vadim Zeitlin
Subject: Re: [lmi] bourn_cast_test with MSVC (was: Don't initialize constexpr variable with std::ldexp())
Date: Tue, 25 Apr 2017 20:00:47 +0200

On Mon, 24 Apr 2017 22:19:46 +0000 Greg Chicares <address@hidden> wrote:

GC> It would be good to know whether at least lmi's unit tests (except for
GC> 'any_member_test') build

 I haven't tried all the tests yet, but while trying the bourn_cast one I
got a warning which affects all of them:

cpp_main.cpp(151): warning C4996: 'setmode': The POSIX name for this item
is deprecated. Instead, use the ISO C and C++ conformant name: _setmode.
See online help for details.

(and the same thing on the next line), so please find attached a trivial
patch fixing this.

GC> I'd especially like to know whether the very recent 'bourn_cast_test'
GC> does.

 While building it, I got several other warnings, here is the complete
list (note that the line numbers refer to the my local sources, i.e. with
the patch disabling MSVC warnings in the header itself applied):

bourn_cast_test.cpp(466): warning C4305: 'initializing': truncation from 'const 
unsigned __int64' to 'float'
bourn_cast_test.cpp(93): warning C4805: '==': unsafe mix of type 
'std::numeric_limits<bool>::_Ty' and type 'const long double' in operation
bourn_cast_test.cpp(716): note: see reference to function template 
instantiation 'void test_same<bool>(const char *,int)' being compiled
bourn_cast_test.cpp(94): warning C4805: '==': unsafe mix of type 
'std::numeric_limits<bool>::_Ty' and type 'const long double' in operation
bourn_cast_test.cpp(169): warning C4245: 'initializing': conversion from 'int' 
to 'CFrom', signed/unsigned mismatch
bourn_cast_test.cpp(759): note: see reference to function template 
instantiation 'void test_signednesses<true,false>(const char *,int)' being 
compiled
bourn_cast_test.cpp(170): warning C4245: 'initializing': conversion from 'int' 
to 'IFrom', signed/unsigned mismatch
bourn_cast_test.cpp(171): warning C4245: 'initializing': conversion from 
'__int64' to 'LFrom', signed/unsigned mismatch
bourn_cast_test.cpp(173): warning C4245: 'initializing': conversion from 'int' 
to 'CTo', signed/unsigned mismatch
bourn_cast_test.cpp(763): note: see reference to function template 
instantiation 'void test_signednesses<false,true>(const char *,int)' being 
compiled
bourn_cast_test.cpp(174): warning C4245: 'initializing': conversion from 'int' 
to 'ITo', signed/unsigned mismatch
bourn_cast_test.cpp(175): warning C4245: 'initializing': conversion from 
'__int64' to 'LTo', signed/unsigned mismatch
bourn_cast.hpp(179): warning C4146: unary minus operator applied to unsigned 
type, result still unsigned
bourn_cast.hpp(333): note: see reference to function template instantiation 'To 
bourn_cast<To,From>(From,std::true_type,std::false_type)' being compiled
        with
        [
            To=unsigned __int64,
            From=float
        ]
bourn_cast_test.cpp(480): note: see reference to function template 
instantiation 'To bourn_cast<unsigned __int64,float>(From)' being compiled
        with
        [
            To=unsigned __int64,
            From=float
        ]
bourn_cast.hpp(192): warning C4805: '!=': unsafe mix of type 'const bool' and 
type 'long double' in operation
bourn_cast.hpp(333): note: see reference to function template instantiation 'To 
bourn_cast<To,From>(From,std::true_type,std::false_type)' being compiled
        with
        [
            To=bool,
            From=long double
        ]
bourn_cast_test.cpp(95): note: see reference to function template instantiation 
'To bourn_cast<T,long double>(From)' being compiled
        with
        [
            To=bool,
            T=bool,
            From=long double
        ]
bourn_cast_test.cpp(716): note: see reference to function template 
instantiation 'void test_same<bool>(const char *,int)' being compiled

I didn't make any effort to look at them in details yet, should I make one
or just disable these warnings in the test too?


 The test also fails during run-time with an uncaught "Cast would
transgress upper limit" exception which happens in
bourn_cast<int64, long double>() called from line 95 of the test, from the
test_same<int64>() function.

 Again, I didn't make any effort to debug this yet, but could try to do it,
of course, if you think it would be useful. If you'd like to understand
what happens here yourself, I can at least tell you that all the variables
appearing here, i.e. "x" and "max" in the test code and "limit" inside
bourn_cast<> itself have the same value, which is 9.2233720368547758e+18
(43e0000000000000 in IEEE-754 representation), which explains why the test
"limit <= from" fails -- they're actually equal.

 Regards,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]