Python Front-end to GCC

John Nagle nagle at animats.com
Sat Oct 26 17:31:32 EDT 2013


On 10/25/2013 12:18 PM, Mark Janssen wrote:
>> As for the hex value for Nan who really gives a toss?  The whole point is
>> that you initialise to something that you do not expect to see.  Do you not
>> have a text book that explains this concept?
> 
> No, I don't think there is a textbook that explains such a concept of
> initializing memory to anything but 0 -- UNLESS you're from Stupid
> University.
> 
> Thanks for providing fodder...
> 
> Mark Janssen, Ph.D.
> Tacoma, WA

    What a mess of a discussion.

    First off, this is mostly a C/C++ issue, not a Python issue,
because Python generally doesn't let you see uninitialized memory.

    Second, filling newly allocated memory with an illegal value
is a classic debugging technique.  Visual C/C++ uses it
when you build in debug mode.  Wikipedia has an explanation:

http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Magic_debug_values

Microsoft Visual C++ uses 0xBAADF00D.  In valgrind, there's
a "-malloc-fill" option, and you can specify a hex value.

There's a performance penalty for filling large areas of memory
so it's usually done in debug mode only, and is sometimes causes
programs with bugs to behave differently when built in debug
vs. release mode.

Sigh.

				John Nagle
				

	





More information about the Python-list mailing list