Re: [Code] Brainteaser

From: John (
Date: 11/21/01

> In effect, nothing.  The top choice is a tiny bit more efficient.
Also, the
> else in the second choice is not necessary, since that line will never
> executed when the top if condition is true.  Here's a more detailed
> explanation of what's going on:

I initially thought that there were no differences between the two
cases. However, when I first broached this subject to several
programmers asking them why the heck the compiler tells me the mud
crashes at this very spot all the time, their first reply was to
separate the OR statement. Martijn's explanation sounds plausible,
although I dont understand why MSVC++ does not opt for "lazy evaluation"
as its default.

The debugger actually says something like:-

(+) str:    0xCC00000 ""
              value cannot be determined

So, I am guessing that the pointer has a NULL string and yet for some
strange reason, it is trying to evaluate *str (I am also guessing that
the memory address is really just part of the freestack) and hence, it
crashes since *str is invalid.

I was stubbornly refusing to separate the statement and kept on
commenting out all other areas I suspect may be the cause of the
crashes. Now that I have separated the statement, it hasnt crashed in
ages (touch wood).

PS: You have the right to point out any flaws :)

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/06/01 PST