svn commit: r235267 - in head/usr.bin/sort: . nls

Konstantin Belousov kostikbel at gmail.com
Fri May 11 13:10:36 UTC 2012


On Fri, May 11, 2012 at 08:57:29AM -0400, David Chisnall wrote:
> On 11 May 2012, at 08:48, Konstantin Belousov wrote:
> 
> > On Fri, May 11, 2012 at 12:37:16PM +0000, Gabor Kovesdan wrote:
> >> Author: gabor
> >> Date: Fri May 11 12:37:16 2012
> >> New Revision: 235267
> >> URL: http://svn.freebsd.org/changeset/base/235267
> > 
> >> +bool byte_sort = false;
> >> +
> >> +static wchar_t **wmonths = NULL;
> >> +static unsigned char **cmonths = NULL;
> > 
> > Such initializations are useless. You only increase the size of the binary
> > on the disk as the consequence.
> 
> Really? The C specification requires all globals and statics that
> are not explicitly initialised to be set to their zero value, so this
> initialisation has no effect on the resulting binary[1]. These are
> placed in the BSS section, irrespective of whether the initialisation is
> implicit or explicit and the loader is responsible for allocating space
> for them - all that is stored in the binary is the size.

The initialized variables are placed in .data and not .bss.
Apparently, some compilers do an optimiziation and put zero-initialized
objects into .bss, as Colin noted, but this is not guaranteed behaviour.
If placed in .data, they do consume disk space.

Redundand initialization is not encouraged by style as well.
> 
> For local variables, initialisation like this has no effect even
> at low optimisation levels - dead stores will be removed. It does,
> however, make it more difficult for the compiler to distinguish between
> initialised and initialised sensibly in some cases.
local variables are irrelevant there.

> 
> David
> 
> [1] In a standards-compliant compiler. Apparently a few shipping
> compilers for embedded systems fail to respect this, but everything
> FreeBSD is compiled with does.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20120511/c8bf282e/attachment.pgp


More information about the svn-src-all mailing list