Skip to content

Commit

Permalink
Fix defect introduced 20050114T1947Z: use before initialization
Browse files Browse the repository at this point in the history
'daily_interest_accounting' had been used before initialization.
Defect identified by ASan [reformatted]:

 #0 in AccountValue::CoordinateCounters()       ihs_acctval.cpp:1486
 #1 in AccountValue::SetInitialValues()         ihs_acctval.cpp:614
 let-me-illustrate#2 in AccountValue::AccountValue(Input const&) ihs_acctval.cpp:109

Fixed by moving the initialization. Resisted the temptation simply
to initialize it in the header, which would have left the defect
intact but restored its invisibility.

Although this defect was introduced 20050114T1947Z into CVS, it comes
from an original file predating the lmi epoch.
  • Loading branch information
Gregory W. Chicares committed Jun 10, 2022
1 parent ade6b59 commit 8340ac5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ihs_acctval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,6 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
LMI_ASSERT(11 == InvariantValues().MecMonth);
LMI_ASSERT(BasicValues::GetLength() == InvariantValues().MecYear );

daily_interest_accounting = contains
(yare_input_.Comments
,"idiosyncrasy_daily_interest_accounting"
);

OldDBOpt = DeathBfts_->dbopt()[0];
// TAXATION !! 'OldSA' and 'OldDB' need to be distinguished for 7702 and 7702A,
// with inclusion of term dependent on 'TermIsDbFor7702' and 'TermIsDbFor7702A'.
Expand Down Expand Up @@ -611,6 +606,10 @@ void AccountValue::SetInitialValues()

Year = InforceYear;
Month = InforceMonth;
daily_interest_accounting = contains
(yare_input_.Comments
,"idiosyncrasy_daily_interest_accounting"
);
CoordinateCounters();

DB7702A = C0; // TODO ?? TAXATION !! This seems silly.
Expand Down

0 comments on commit 8340ac5

Please sign in to comment.