lmi
[Top][All Lists]
Advanced

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

[lmi] MSVC warnings for comparisons in bourn_cast


From: Vadim Zeitlin
Subject: [lmi] MSVC warnings for comparisons in bourn_cast
Date: Tue, 25 Apr 2017 15:54:13 +0200

 Hello,

 Compiling 2f1ceccc32f0faa5a78045d7ae2b182f01f1ce9f with MSVC I get many
warnings about comparisons in bourn_cast.hpp, here is just a small but,
I think, representative sample of them:


bourn_cast.hpp(231): warning C4018: '<': signed/unsigned mismatch (compiling 
source file default_view.cpp)
         bourn_cast.hpp(327): note: see reference to function template 
instantiation 'To bourn_cast<To,From>(From,std::true_type,std::true_type)' 
being compiled
                 with
                 [
                     To=numeric_conversion_traits<char>::T,
                     From=unsigned long
                 ] (compiling source file default_view.cpp)
bourn_cast.hpp(233): warning C4018: '<': signed/unsigned mismatch (compiling 
source file default_view.cpp)
bourn_cast.hpp(231): warning C4804: '<': unsafe use of type 'bool' in operation 
(compiling source file default_view.cpp)
         bourn_cast.hpp(327): note: see reference to function template 
instantiation 'To bourn_cast<To,From>(From,std::true_type,std::true_type)' 
being compiled
                 with
                 [
                     To=numeric_conversion_traits<bool>::T,
                     From=long
                 ] (compiling source file default_view.cpp)
         numeric_io_traits.hpp(208): note: see reference to function template 
instantiation 'To bourn_cast<numeric_conversion_traits<bool>::T,long>(From)' 
being compiled
                 with
                 [
                     To=numeric_conversion_traits<bool>::T,
                     From=long
                 ] (compiling source file default_view.cpp)
bourn_cast.hpp(233): warning C4804: '<': unsafe use of type 'bool' in operation 
(compiling source file default_view.cpp)

In all I get many hundreds line of output because the same warnings are
given for many different source files.

 As always, I could disable these warnings globally, but I'd be very
reluctant to do it because both of them are generally useful. I also
probably could (but I didn't test it yet) disable the warnings just in this
code using pragmas, as it's already done for gcc, which seems to be the
best approach, but would require having MSVC-specific pragmas in this
header and so I wanted to ask you about it before making a patch. But I
also wonder if we couldn't avoid the warnings in the first place. I'm not
brave enough to even try proposing the solution for the first one
(signed/unsigned mismatch), but it looks like we could avoid at least the
second one by using a specialization of these comparisons for bool. Would
it be worth doing this?

 Regards,
VZ


reply via email to

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