lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Suspected stack corruption


From: Greg Chicares
Subject: Re: [lmi] Suspected stack corruption
Date: Fri, 11 Dec 2015 13:34:31 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0

On 2015-12-10 13:46, Greg Chicares wrote:
> I'm planning a change to move a const_cast deep into a library where it
> belongs. While exploring ways to test it, I inserted the following
> deliberate mistake:

We don't intend to put a mistake like that into production, so fixing
the underlying issue in wx is not urgent.

Here's the reason why I did such a strange thing in the first place. I
wanted to be sure it was as safe as possible to commit this revision:
  http://svn.savannah.nongnu.org/viewvc?view=rev&root=lmi&revision=6434
because there isn't much time for testing this month's release due to the
holidays. The non-GUI code is protected by a unit test, and I wanted some
extra assurance for the GUI part:
  
http://svn.savannah.nongnu.org/viewvc/lmi/trunk/census_view.cpp?root=lmi&r1=6434&r2=6433&pathrev=6434&diff_format=u
To emulate the effect of getting those conditions wrong, I deliberately
scrambled them as a throwaway test before committing.

I might instead have done something like this:
    bool const x0 = typeid(mce_yes_or_no Input::*) == value.type();
    bool const y0 = exact_cast<mce_yes_or_no>(value);
    LMI_ASSERT(x0 == y0);
    // ... and similarly for the other conditions
Scrambling them just seemed easier and more interesting.

As for this part:
     if(...
     ...
     else if(...
     ...
         {
-        // else: fall through
+        }
+    else
+        {
+        ; // Fall through.
         }
I figure that it's preferable to express a control structure in code
rather than comments. Perhaps someday we'll use an automated tool
that looks for code smells like 'if...else if...else if' with no
catch-all 'else' at the end.




reply via email to

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