Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 May 2012 16:09:55 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        David Chisnall <theraven@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Gabor Kovesdan <gabor@freebsd.org>
Subject:   Re: svn commit: r235267 - in head/usr.bin/sort: . nls
Message-ID:  <20120511130955.GO2358@deviant.kiev.zoral.com.ua>
In-Reply-To: <6AE99277-D90F-453D-AE40-EE731DFD3BAB@FreeBSD.org>
References:  <201205111237.q4BCbGX2083596@svn.freebsd.org> <20120511124820.GN2358@deviant.kiev.zoral.com.ua> <6AE99277-D90F-453D-AE40-EE731DFD3BAB@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--OpylS7L25zwHG0dS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, May 11, 2012 at 08:57:29AM -0400, David Chisnall wrote:
> On 11 May 2012, at 08:48, Konstantin Belousov wrote:
>=20
> > 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
> >=20
> >> +bool byte_sort =3D false;
> >> +
> >> +static wchar_t **wmonths =3D NULL;
> >> +static unsigned char **cmonths =3D NULL;
> >=20
> > Such initializations are useless. You only increase the size of the bin=
ary
> > on the disk as the consequence.
>=20
> 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.
>=20
> 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.

>=20
> David
>=20
> [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.

--OpylS7L25zwHG0dS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAk+tD6MACgkQC3+MBN1Mb4hi0gCfVDlGEYE0YUxXCKY4chkd/3cb
98wAoKFhikWfcz1UoO1ZArgMWHBob+ui
=F/Dd
-----END PGP SIGNATURE-----

--OpylS7L25zwHG0dS--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120511130955.GO2358>