Re: [PATCH] Clean up struct initalizations

From: Date: Tue, 27 Nov 2007 18:27:26 +0000
Subject: Re: [PATCH] Clean up struct initalizations
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-33466@lists.php.net to get a copy of this message
you are quoting c99… and we are still using "c90" mode, as far as I remember On 11/27/07, Stanislav Malyshev <stas@zend.com> wrote: > > a global struct is filled up with NULL/0's while a local struct is not > > initialized at all. The patch simply provides more correct code and even > > That's not what I read in C standard - it says that if struct is > partially initialized, the rest is zeroed out: > > Quoting http://c0x.coding-guidelines.com/6.7.8.html: > > 1671 If there are fewer initializers in a brace-enclosed list than there > are elements or members of an aggregate, or fewer characters in a string > literal used to initialize an array of known size than there are > elements in the array, the remainder of the aggregate shall be > initialized implicitly the same as objects that have static storage > duration. > > 1642 If an object that has static storage duration is not initialized > explicitly, then: > 1643 — if it has pointer type, it is initialized to a null pointer; > 1644 — if it has arithmetic type, it is initialized to (positive or > unsigned) zero; > 1645 — if it is an aggregate, every member is initialized (recursively) > according to these rules; > 1646 — if it is a union, the first named member is initialized > (recursively) according to these rule > > All compilers I know do behave this way. Do not confuse partial > initialization wiht no initialization at all, of course. > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/

« previous php.internals (#33466) next »