summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-06 16:57:12 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-06 16:57:12 -0400
commit0c42147fabaef31a2c577fc009dec354447c2e7f (patch)
tree6c1bfbbef656b818f026a371136d345e88a41c71
parent8c68abb2f63d54aeb4614c63a109b838ed8d0656 (diff)
Avoid VC fatal warning when trying to fix un/signed comparison.
-rw-r--r--indra/llcommon/lldefs.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index ed075e8d96..d4b063f88c 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -183,16 +183,23 @@ inline bool llless(T0 d0, T1 d1)
// T0 signed, T1 unsigned: negative d0 is less than any unsigned d1
if (d0 < 0)
return true;
+ // both are non-negative: explicitly cast to avoid C4018
+ return std::make_unsigned_t<T0>(d0) < d1;
}
else if constexpr (! std::is_signed_v<T0> && std::is_signed_v<T1>)
{
// T0 unsigned, T1 signed: any unsigned d0 is greater than negative d1
if (d1 < 0)
return false;
+ // both are non-negative: explicitly cast to avoid C4018
+ return d0 < std::make_unsigned_t<T1>(d1);
+ }
+ else
+ {
+ // both T0 and T1 are signed, or both are unsigned:
+ // straightforward comparison works
+ return d0 < d1;
}
- // both T0 and T1 are signed, or both are unsigned, or both non-negative:
- // straightforward comparison works
- return d0 < d1;
}
// recursion tail