Yo Hal!

> On Thu, 29 Aug 2019 14:06:25 -0700
> Hal Murray via devel <devel@ntpsec.org> wrote:
> 
> > >> By "floating", you mean uninnitialized?  In C that's going to
> > >> mean it's     
> > false
> >   
> > > Yes. My understanding of C is that anything not explicitly set has
> > > whatever random value happens to be in that memory location.
> > > Possibly  changed if certain unknown compiler options are chosen.
> > >     
> > 
> > I thought global variables were initialized to zero.  
> 
> 
> C11 states, page 12, section 5.1.2.2:
> 
> "All objects of static storage duration shell be initialized (set to
> their initial values) before program startup.  The manner and timing
> of such initializations are otherwise unspecified."
> 
> In this case, as defined in 6.2.4, "static" just means always
> allocated (not on the stack, etc.).
> 
> So, IMHO, you can't expect zeros.

Correction.  My mistake.  

Hal you are corect.  Page 140, section 6.7.9 Initialization.

"If an object that has static or thread storage duration is not initialized
explicitly, then:
[...]
-- if it has arithmetic tye, it is initialized to (positive or unsigned)
zero;"

So static storage items are initialized for at least C11.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        g...@rellim.com  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpUOqa2jwOjv.pgp
Description: OpenPGP digital signature

_______________________________________________
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to