lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Census pasting [Was: Allow direct drill-down editing in census


From: Greg Chicares
Subject: Re: [lmi] Census pasting [Was: Allow direct drill-down editing in census manager]
Date: Thu, 29 Jul 2010 11:51:17 +0000
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

On 2010-07-28 20:52Z, Greg Chicares wrote:
> [...] Code such as this:
> 
>   bool CensusView::DoAllCells(mcenum_emission emission)
>   {
>       assert_consistency(case_parms()[0], cell_parms()[0]);
> 
> assumes that cell_parms() is not empty. I suppose I should add
> appropriate assertions to the accessors.

Not so fast. Changing six accessors this way (e.g.):

 inline std::vector<Input> const& CensusView::case_parms() const
 {
-    return document().doc_.case_parms_;
+    std::vector<Input>& z(document().doc_.case_parms_);
+    LMI_ASSERT(!z.empty());
+    return z;
 }

wouldn't guard against a potential segfault in places like this:
    Input& original_parms = cell_parms()[cell_number];

IOW, std::vector::at() was not designed to throw std::out_of_range iff
the vector is empty, so it seems like a mistake to do that here. And
I don't want to do anything elaborate because this module will soon be
replaced.

But in revision 5085 of 20100729T0212Z I did assert some postconditions
in CensusView::UponPasteCensus() only. That function is an event handler,
so it's not exercised by normal automated system tests; extra caution is
warranted also because of the severe problem there that went unreported
for so long.



reply via email to

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