From fb602a449731fcdd6734646c5446a4f95eb78fcd Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Wed, 12 Jan 2022 09:47:40 -0500 Subject: [PATCH] Try fixing "unreachable code" warning on MSVC 14.2 This doesn't show up on any other compiler, including MSVC 14.3, so I think it's just a compiler bug. Cursory googling suggests perhaps that some older versions of MSVC have immature support for `if constexpr`. --- src/core/include/units/magnitude.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index df2b5507..c9013bd1 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -306,12 +306,14 @@ constexpr auto operator*(magnitude, magnitude) { return magnitude{} * partial_product; } } + // Case for when H1 has the smaller base. - else if constexpr(H1.get_base() < H2.get_base()){ + if constexpr(H1.get_base() < H2.get_base()){ return magnitude

{} * (magnitude{} * magnitude{}); } + // Case for when H2 has the smaller base. - else { + if constexpr(H1.get_base() > H2.get_base()){ return magnitude

{} * (magnitude{} * magnitude{}); } }