[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] [PATCH] Add a cast to fix compilation in 64 bits
From: |
Vadim Zeitlin |
Subject: |
[lmi] [PATCH] Add a cast to fix compilation in 64 bits |
Date: |
Sun, 5 Mar 2017 21:05:46 +0100 |
Hello,
Here is the smallest possible patch fixing the build under 64 bit Unix
systems after the changes of 75129caf03f5a5e0dd1850c6be4f06a5f231eaf9 which
resulted in an ambiguity when calling std::min<>() with the arguments of
type "long int" and "int":
---------------------------------- >8 --------------------------------------
>From 3526d20b7f4c7ba15340981ff21b1e2a1384e2ce Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <address@hidden>
Date: Sun, 5 Mar 2017 21:01:47 +0100
Subject: [PATCH] Add a cast to fix compilation in 64 bits
Under 64 bit Unix systems the difference between two iterators, which
has std::ptrdiff_t type, is not of type "int" and hence we need an
explicit cast to make the call to std::min<>() unambiguous.
---
ledger.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ledger.cpp b/ledger.cpp
index ba6f8d3..1db9e62 100644
--- a/ledger.cpp
+++ b/ledger.cpp
@@ -172,7 +172,7 @@ void Ledger::ZeroInforceAfterLapse()
}
std::vector<double>::iterator b = ledger_invariant_->InforceLives.begin();
std::vector<double>::iterator e = ledger_invariant_->InforceLives.end();
- b += std::min(e - b, 1 + lapse_year);
+ b += std::min(static_cast<int>(e - b), 1 + lapse_year);
if(b < e)
{
std::fill(b, e, 0.0);
--
2.8.0.rc1
---------------------------------- >8 --------------------------------------
Personally, I'd rather use InforceLives.size() and InforceLives.empty()
here too, but this is much less important than making this code compile in
the first place.
Thanks in advance for applying this!
VZ
- [lmi] [PATCH] Add a cast to fix compilation in 64 bits,
Vadim Zeitlin <=