Group: comp.lang.c++
From: James Kanze
Date: Friday, February 15, 2008 2:38 PM
Subject: Re: difference between calloc() and malloc()

On Feb 15, 5:46 pm, Jeff Schwab wrote:
> James Kanze wrote:

[...]
> >> AFAIK, static objects are guaranteed to be zero'd by all conformant
> >> implementations, too.

> > They are guaranteed to be "zero initialized". That doesn't
> > necessarily mean all bits 0.

> That is an interesting distinction. Do you happen to know of
> any modern platforms for which "zero initialized" POD objects
> require memory with non-zero bit-patterns?

Off hand, no, but that doesn't mean that one would surprise me.

> I spent some years working with microprocessor design teams, and
> 0xdeadbeef was a common starting value for buses during simulations, to
> make it clear that no value had yet been assigned to the bus. The only
> time I've seen even a vaguely similar technique used in software is for
> the magic numbers that sometimes identify file types, e.g. the
> 0xcafebabe at the beginning of Java .class files.

I'm certain that I've seen it somewhere. I use it in my debug
operator new/operator delete, but I certainly didn't invent it.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34