On Sat, Nov 09, 2002 at 11:09:39AM -0000, [EMAIL PROTECTED] wrote:

>   -    /* Initialize the integer register chunk */
>   -    interpreter->ctx.int_reg_base->used = 0;
>   +    /* Initialize the register chunks */
>        interpreter->ctx.int_reg_base->free = FRAMES_PER_INT_REG_CHUNK;
>   -    interpreter->ctx.int_reg_base->next = NULL;
>   -    interpreter->ctx.int_reg_base->prev = NULL;

By doing this you are assuming that the in memory representation of a NULL
pointer is all bits NULL. This isn't guaranteed. (What *is* guaranteed by
the standard is that a NULL pointer casts to 0, and that all other pointers
cast to non-zero)

It's not likely to be a portability problem, as I seem to remember that the C
FAQ is only able to mention one very obscure platform where NULL was not all
bits zero in memory. (Sorry, not online at the moment, so no URL) However, I
have a niggling thought that someone telling me that some compiler product in
memory leak debug mode (possibly a Microsoft compiler) was able to have NULL
pointers *not* stored as all bits zero in memory, and so could fault confusion
between 0 and NULL

I believe that a bigger assumption (not sure if we're making it; didn't spot
it) is that float 0.0 and double 0.0 are written as all bits zero in memory.

Nicholas Clark
-- 
Brainfuck better than perl?     http://www.perl.org/advocacy/spoofathon/

Reply via email to