lmi
[Top][All Lists]
Advanced

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

[lmi] MSVS compilation problem with 100_cents in ternary operator


From: Vadim Zeitlin
Subject: [lmi] MSVS compilation problem with 100_cents in ternary operator
Date: Tue, 18 May 2021 02:33:57 +0200

 Hello,

 I've tried building the latest master with MSVS and it complains about
using operator _cents in non-constant expression when it's used in the
following line

        return InvariantValues().IsMec ? -100_cents : 100_cents;

of ihs_avsolve.cpp.

 I'm not sure if this is a compiler bug or the expression is really
non-constant (which could be the case if it's only the whole expression and
not each of the 2 subexpressions, that counts), but in any case doing
something like this

---------------------------------- >8 --------------------------------------
diff --git a/ihs_avsolve.cpp b/ihs_avsolve.cpp
index ed12df6c1..995d77dfd 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -249,7 +249,8 @@ currency AccountValue::SolveTest(currency a_CandidateValue)
 
     if(mce_solve_for_non_mec == SolveTarget_)
         {
-        return InvariantValues().IsMec ? -100_cents : 100_cents;
+        constexpr auto C100 = 100_cents; // one dollar
+        return InvariantValues().IsMec ? -C100 : C100;
         }
 
     return value - SolveTargetCsv_;
---------------------------------- >8 --------------------------------------

partially reverting the changes of 237cf7245 (Use currency operator""
_cents(), 2021-05-08) here would fix it.

 Do you think we could do this or should I look more into this and, at
least, ascertain whether it's really a compiler bug or not? To be honest,
I'd prefer to make the simple change above to continue working on other,
more useful, things right now, and while I'd understand if you didn't want
to make the code uglier to just accommodate MSVS, the version above doesn't
really seem to be that much worse than the current one to me, so I hope we
could just use it.

 Thanks in advance,
VZ

Attachment: pgpzQ3JDfg_G8.pgp
Description: PGP signature


reply via email to

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