From 22cc84ab23bf920f1de6038a8e2c2580ad2d59c8 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Sun, 15 Dec 2019 08:49:51 -0700 Subject: [PATCH] Better fix for all compilers The Nvidia compiler complained about unreachable code with original throw followed by return 0. However, if the return 0 was removed, then the MSC compiler complained about function not returning value. This was due to the use of `FMT_THROW` which "tricks" the MSC compiler into thinking it is possible for the `FMT_THROW` to return. If we just use the `thow format_error(...)` here with no return, then all compilers should be able to deduce that the code will not return following the explicit throw and it should eliminate all warnings from Nvidia, MSC, and other compilers. --- include/fmt/printf.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 9fa329b3..fb062804 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -45,10 +45,7 @@ class printf_precision_handler { template ::value)> int operator()(T) { - FMT_THROW(format_error("precision is not integer")); -#if FMT_MSC_VER - return 0; -#endif + throw format_error("precision is not integer"); } }; @@ -168,10 +165,7 @@ template class printf_width_handler { template ::value)> unsigned operator()(T) { - FMT_THROW(format_error("width is not integer")); -#if FMT_MSC_VER - return 0; -#endif + throw format_error("width is not integer"); } };