OFF-TOPIC: if (blah) ...

From: Daniel A. Koepke (dkoepke@california.com)
Date: 08/12/99


Today, Chris Proctor spake to the list:

> Then why would if (blah) cause problems where if (blah != NULL) does
> not?

A valid point.

> Surely if blah is not equal to NULL and if's behaviour is as specified
> they should be functionally identical. They are certainly not in this
> particular case.

They, however, *are*.  This isn't a matter of debate.  I'm not
extrapolating that "if (blah)" and "if (blah != NULL)" are functionally
equivalent in the case of pointers; I'm stating an established fact.  No
vendor of the C language would change this: it would break most, if not
all, code available, destroy ANSI C compliancy, and go against a large
part of the design philosophy of the C language.  I can assure that the
two are the same.  Any difference in functionality you think you're
experiencing is NOT from the two.  Memory overruns are transient.  Even if
you do exactly the same thing, the results can be drastically different.

> Admittedly I've changed a lot of the rest, but the socket and
> descriptor stuff I've left well alone.

Which is why I speculate it's a memory overrun.  C does not do runtime
bounds checking, therefore if you write more bytes to a memory address
than is allocated, the extra bytes will end up being written into other
memory.  This often doesn't cause a crash because the overrun ends up into
memory that also belongs to the program (thus, no segmentation fault).
This means that it's quite conceivable you could fudge a 'next' pointer in
descriptor_data without directly touching it.

> I acknowledge the possibility that something I've changed elsewhere
> has impacted on it, but it doesn't seem like from this end.

I assure you, I'm not merely suggesting it as a possibility that it's your
code that's broken.  I'm telling you flat out that it IS your code.

-dak : Nnnooo...I did not just see a trailer attribute a review quote to
       Aint-it-cool-news.  I think I'm going to buy into that whole Y2K
       disaster theory now...


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST