Full Disclosure mailing list archives
Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!)
From: silvio () big net au (silvio () big net au)
Date: Sun, 15 Sep 2002 14:50:27 -0700
On Sun, Sep 15, 2002 at 09:06:57AM -0500, Jacques A. Vidrine wrote:
_The C Programming Language_, 2nd edition says it most clearly on p219: ``A static object not explicitly initialized is initialized as if it (or its members) were assigned the constant 0.'' ISO/IEC 9899:1999 (C99) is a bit more verbose (section 6.7.8 paragraph 10): ``If an object that has static storage duration is not initialized explicitly, then: if it has pointer type, it is initialized to a null pointer; if it has arithmetic type, it is initialized to (positive or unsigned) zero; if it is an aggregate, every member is initialized (recursively) according to these rules; if it is a union, the first named member is initialized (recursively) according to these rules. ''must suck to port :)Yes, it does, but not for this reason. Cheers,
heh. thanks for the quick reply (which also happens to be accurate!) ;-) Looking at the isoc specs you mention, you are infact correct here :) It appears I have been misinformed on this topic! heh. thanks for clarifaction. erm.. this is something interesting however. For static storage initialization of a union, then yes, the specs say the first member is initializated.. but the size of a union is not necessary the size of the first member, but a size sufficient to contain the largest of its members (6.7.2.1 - 14). does this seem true? Personally though, without even looking at the specs.. I much prefer all initialization to be explicit :) OK.. its obvious the C specifications are not my strong point, and to be honest, I've never fully read them.. so please go easy on me :) -- Silvio
Current thread:
- ALERT ALERT ALERT! google under attack ALERT ALERT ALERT! silvio () big net au (Sep 15)
- <Possible follow-ups>
- ALERT ALERT ALERT! google under attack ALERT ALERT ALERT! silvio () big net au (Sep 15)
- C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Jacques A. Vidrine (Sep 15)
- C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Jacques A. Vidrine (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) silvio () big net au (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Michal Zalewski (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) silvio () big net au (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Dotho (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Michal Zalewski (Sep 15)