lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Pagination anomaly


From: Greg Chicares
Subject: Re: [lmi] Pagination anomaly
Date: Thu, 8 Feb 2018 13:40:29 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 2018-02-06 20:25, Greg Chicares wrote:
> On 2018-02-06 14:21, Vadim Zeitlin wrote:
>> On Tue, 6 Feb 2018 12:52:39 +0000 Greg Chicares <address@hidden> wrote:
>> GC> [...] have we
>> GC> agreed that it's generally preferable for enumerative 'switch'
>> GC> statements to write a 'case' for every enumerator, and rely on the
>> GC> compiler to identify any missing case?
>> 
>>  There are 2 possibilities: the first one is to do this, relying on the
>> "default" (because included in -Wall) -Wswitch to detect the missing cases.
>> The second one is to explicitly use -Wswitch-enum
[...snip disadvantages of '-Wswitch-enum'...]
> 
> I hadn't thought of trying '-Wswitch-enum'. Of course we don't want to
> use it regularly, but running it once, just to see what happens, was
> interesting. For example, in 'ihs_avsolve.cpp', there's a
>   switch(a_SolveType)
> with a case for every enumerator except the one indicating that no solve
> is desired. If no solve is desired, then this switch shouldn't be reached.
> Adding that "impossible" case and treating it as a logic error enables
> our customary '-Wswitch' to detect any other missing enumerator at run
> time, which is an improvement.
[...]
>> GC> Maybe I should remove 'default:' wherever possible throughout
>> GC> lmi, once and for all.

I've removed about fifty cases (a little more than half).

>> It also won't be completely
>> trivial, some default labels can't be removed easily even if they look
>> superficially similar to the ones that can. E.g. the switch in
>> Ledger::SetRunBases() contains one which looks very similar to the one in
>> pdf_writer_wx.cpp, but the switch there doesn't have cases for several enum
>> elements (mce_variable_annuity and 3 more mce_xxx_obsolete values).
> 
> Rather than discuss this one theoretically, I'll just commit my idea
> for making these two files similar and see what you think of it.

More interestingly, in 'progress_meter_test.cpp', we used to try
creating an object with
  progress_meter::enum_display_mode(99)
which, AFAICT, was "unspecified" when it was written ages ago, but has
become UB due to CWG defect 1766:
  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1766
Anyway, the "unspecified" behavior used to be caught by the 'default:'
case, at least in practice; but now, with no 'default:' case, it
"passed", yet that's just UB, so I removed the test.

Numerical system-test results have changed, as they so often do when
we change code in ways that seem unlikely to change numerical results.
This is why we need to use the integer-based currency class, when we
find the time. Until then, we have to deal with nuisance changes. The
pattern observed here is typical (some of these tests use proprietary
products, but none of the text pasted below leaks any proprietary data):

System test:
gv1.000000001.test   Summary: max abs diff: 4.54747e-013 max rel err:  
1.97505e-014
gv1.000000005.test   Summary: max abs diff: 3.63798e-012 max rel err:  
1.57982e-014
gv1.000000007.test   Summary: max abs diff: 9.09495e-013 max rel err:  
1.35285e-014
gv1.000000008.test   Summary: max abs diff: 3.63798e-012 max rel err:  
1.33085e-014
gv1.000000009.test   Summary: max abs diff: 1.81899e-012 max rel err:  
2.5148e-014
gv1.000000010.test   Summary: max abs diff: 1.81899e-012 max rel err:  
1.43381e-014
gv1.000000012.test   Summary: max abs diff: 1.81899e-012 max rel err:  
1.01412e-014
gv1.000000038.test   Summary: max abs diff: 2.91038e-011 max rel err:  
2.5047e-014
gv1.000000041.test   Summary: max abs diff: 1.81899e-012 max rel err:  
2.38459e-014
gv1.000000042.test   Summary: max abs diff: 1.45519e-011 max rel err:  
1.15163e-013
sample.000000000.test   Summary: max abs diff: 0.02 max rel err:  4.99023e-011
sample.000000036.test   Summary: max abs diff: 0.01 max rel err:  5.70609e-009
sample.000000037.test   Summary: max abs diff: 0.01 max rel err:  5.70609e-009
td5.000000092.test   Summary: max abs diff: 0.01 max rel err:  3.41905e-009
Files /opt/lmi/test/md5sums-20180208T1052Z and /opt/lmi/touchstone/md5sums 
differ
*** System test failed ***
  1512 system-test files compared
  1444 system-test files match
  68 system-test files differ
  0 system-test files missing
...system test completed.

Relative errors less than 1e-14 are filtered out of the seriatim list,
and reported only in the summary. A difference of epsilon snowballs
through compound interest across up to a hundred years of twelve months
each, easily reaching that 1e-14 threshold in many cases and sometimes
exceeding it, leading to absolute errors of one or two cents.



reply via email to

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