lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master fb7c030b 10/24: Work around clang '-Wno-unrea


From: Greg Chicares
Subject: [lmi-commits] [lmi] master fb7c030b 10/24: Work around clang '-Wno-unreachable-code-return'
Date: Fri, 8 Jul 2022 07:11:26 -0400 (EDT)

branch: master
commit fb7c030babab1edf204d7130c72187f64df078b0
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Work around clang '-Wno-unreachable-code-return'
    
    Commenting the alternative code out with "#if 0 ... #endif" is
    undesirable because it would promote software rot.
    
    The clang maintainers have discussed tricks like
      if((true))
    where the extra parentheses prevent the warning. This revision does
    much the same thing, but in a standard way.
---
 gpt_server.cpp         | 5 +++++
 stratified_charges.cpp | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/gpt_server.cpp b/gpt_server.cpp
index c19941af..f25b3383 100644
--- a/gpt_server.cpp
+++ b/gpt_server.cpp
@@ -77,7 +77,12 @@ gpt_state test_one_days_gpt_transactions
     s["X5_gsp_b"] = value_cast<std::string>(o.GuidelineSinglePremiumPolicyB);
     s["X6_glp_c"] = value_cast<std::string>(o.GuidelineLevelPremiumPolicyC );
     s["X7_gsp_c"] = value_cast<std::string>(o.GuidelineSinglePremiumPolicyC);
+    // Return here, but retain alternative below.
+volatile bool avoid_warning {true};
+if(avoid_warning)
+    {
     return s;
+    }
 
     bool                        Use7702ATables               = 
exact_cast<mce_yes_or_no           >(input["Use7702ATables"              
])->value();
 //  int                         IssueAge                     = 
exact_cast<tnr_age                 >(input["IssueAge"                    
])->value();
diff --git a/stratified_charges.cpp b/stratified_charges.cpp
index aa83447e..8c86ed60 100644
--- a/stratified_charges.cpp
+++ b/stratified_charges.cpp
@@ -418,7 +418,12 @@ double 
stratified_charges::minimum_tiered_sepacct_load_for_7702() const
 {
     stratified_entity const& z = datum("CurrSepAcctLoadTieredByAssets");
     LMI_ASSERT(!z.values().empty());
+    // Return here, but retain alternative below.
+volatile bool avoid_warning {true};
+if(avoid_warning)
+    {
     return *std::min_element(z.values().begin(), z.values().end());
+    }
 
     stratified_entity const& z0 = datum("CurrSepAcctLoadBandedByAssets");
     stratified_entity const& z1 = datum("CurrSepAcctLoadBandedByPrem");



reply via email to

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