Re: asserts

From: Patrick Lam (plam@plam.lcs.mit.edu)
Date: Thu Apr 18 2002 - 01:43:03 EDT

  • Next message: Mike Nordell: "Re: asserts"

    On Thu, Apr 18, 2002 at 07:34:27AM +0200, Mike Nordell wrote:
    > Patrick Lam wrote:
    >
    > > I claim that excessive asserting (I would not assert BOOL \in {true,
    > false})
    > > is bad style,
    >
    > So you do, and I have found more than a few bugs because of just that. Yes,
    > exactly that. UT_Bool that was anything but 0 or 1 and was used with that
    > uninitlialize value.

    I'm pretty sure that valgrind detects accesses to uninitialized memory too.

    > > because it makes program logic hard to follow.
    >
    > An assert that makes the program logic _hard_ to follow???

    it's like commenting:

         // increment x
         x = x + 1;

    UT_ASSERT(b == true || b == false);
    is going to obscure program logic because you have to wade through
    crud.

    > > Surprising
    > > asserts should be there (like when we think that something might happen
    > > to be false) but not unsurprising asserts.
    >
    > ??? Now you lost me. Surprising asserts should be there, but unsurpising
    > asserts should not?

    Something like UT_ASSERT(pNext != NULL); would be a useful assert, as opposed
    to UT_ASSERT(b == true || b == false);

    pat



    This archive was generated by hypermail 2.1.4 : Thu Apr 18 2002 - 01:43:48 EDT