lmi
[Top][All Lists]
Advanced

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

[lmi] MSVC warnings


From: Vadim Zeitlin
Subject: [lmi] MSVC warnings
Date: Sun, 5 Jun 2022 17:22:43 +0200

 Hello,

 I wanted to report the full list of warnings in the MSVC build, but while
I was thinking about doing it, you've already fixed almost all of them
(thanks a lot!). Unfortunately, there is also a new warning now, which is
given many (a couple of dozens) times and, because it's in the template
code, each of its occurrences results in a dozen lines of compiler
diagnostics, showing where the template was instantiated from. This warning
is

math_functions.hpp(149,1): warning C4146: unary minus operator applied to
unsigned type, result still unsigned

(line 149 in b6916ab8e (Avoid deprecated enum conversions, 2022-06-03) that
I am testing this with is the last line of the u_abs() function) and I
think it's a pretty useful warning that it would be a pity to disable
because it I already wrote incorrect code that was flagged by this warning
even if in this particular case it's almost certainly done intentionally
and works as intended. But could we perhaps use "~t+1" instead of "-t"
here? As we're guaranteed 2-complement representation in C++ now, it should
do exactly the same thing even in theory now, and not just in practice.


 Except for this warning, there are only a few more:

1. First one is in PETE code used from i7702.cpp (I omit the full page of
   intermediate messages, but please let me know if you need them):

tools\pete-2.1.1\PETE\OperatorTags.h(531,18): warning C4805: '==': unsafe
mix of type 'const T1' and type 'const T2' in operation with T1=bool and
T2=double
...
i7702.cpp(242): see reference to function template instantiation
'bool AllOf<T>(const Expression<T> &)' being compiled

   This could be fixed by just using 1.0 and 0.0 instead of true/false.
   Perhaps we could define some LMI_TRUE as (constexpr) double 1.0?

2. Same warning but directly in ihs_acctval.cpp:

ihs_acctval.cpp(421,5): warning C4805: '==': unsafe mix of type 'bool' and
type 'double' in operation

   This could again be fixed by just using 0.0 instead of false.


3. Finally, there is also a warning given inside wx headers when building
   lmi

wxWidgets\include\wx\unichar.h(396,55): warning C4459: declaration of 'c2' 
hides global declaration
zero.hpp(1158,12): message : see declaration of 'c2'

   I guess it's really wx's fault for using "c2" as the name of a parameter
   in this function:

inline int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); }

   but OTOH we have to use _something_ as parameter names and prefixing
   them all with "wx" would make things unbearably ugly (as can be seen by
   a quick glance at any standard library headers, and "_" that they
   typically use is still more readable than "wx"). So I wonder if we could
   perhaps avoid this by moving c2 and c3 declarations inside rroot_()
   instead of keeping them in the global namespace? Alternatively, we could
   put them in some lmi_zero namespace or something like (but using unnamed
   namespace wouldn't work, i.e. would still result in this warning).


 Anyhow, thanks again for fixing the tons of deprecated operations with
enum warnings and it would be great if the warning in math_functions.hpp
could be fixed too. The others are less annoying, but this one really is.
And if the others could be fixed too, it would be simply perfect.

 Thanks in advance,
VZ

Attachment: pgpMthQWSZqW7.pgp
Description: PGP signature


reply via email to

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