Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Mar 2004 01:54:17 +0200
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Dag-Erling Sm?rgrav <des@des.no>
Cc:        net@freebsd.org
Subject:   Re: libalias patch for review / testing
Message-ID:  <20040316235417.GC65466@ip.net.ua>
In-Reply-To: <xzpn06ggycp.fsf@dwp.des.no>
References:  <xzp7jxkjv98.fsf@dwp.des.no> <xzp3c88jv7k.fsf@dwp.des.no> <20040316225230.GO3462@ip.net.ua> <xzpllm0ie5z.fsf@dwp.des.no> <20040316232848.GR3462@ip.net.ua> <xzpn06ggycp.fsf@dwp.des.no>

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

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

On Wed, Mar 17, 2004 at 12:34:46AM +0100, Dag-Erling Sm?rgrav wrote:
> Ruslan Ermilov <ru@freebsd.org> writes:
> > : `-fstrict-aliasing'
> > :      Allows the compiler to assume the strictest aliasing rules
> > :      applicable to the language being compiled.  For C (and C++), this
> > :      activates optimizations based on the type of expressions.  In
> > :      particular, an object of one type is assumed never to reside at
> > :      the same address as an object of a different type, unless the
> > :      types are almost the same.  For example, an `unsigned int' can
> > :      alias an `int', but not a `void*' or a `double'.  A character ty=
pe
> > :      may alias any other type.
> >
> > And asking myself a question: should those (void *)'s in your patch
> > be (char *)'s instead, e.g., in twowords() and DifferentialChecksum(),
> > or am I misreading the above?
>=20
> You're misreading, we're doing u_short * <-> void * (both pointers)
> but the man page speaks about int <-> void * (scalar vs pointer)
>=20
OK, I stand corrected.  ;)

> Also, I doubt DifferentialChecksum() is a problem, since it's a
> function call.  I think the problem may be in the code I've replaced
> with calls to twowords().
>=20
Hmm, now that I think about it more, since -O2 turns -fstrict-aliasing,
and the latter may produce broken code if strict aliasing rules are
broken by the source, I think people (and tinderboxes!) should compile
with ``-O2 -Wstrict-aliasing'' in CFLAGS rather than just -O2.  For
WARNS > 1 compiled code, this will be a no-op (as -Wall implies
-Wstrict-aliasing), but it should help catch bugs related to breaking
strict aliasing like in libalias, in code that is otherwise compiled
without warnings.


Cheers,
--=20
Ruslan Ermilov
FreeBSD committer
ru@FreeBSD.org

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

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

iD8DBQFAV5OpUkv4P6juNwoRAkGQAJ4sQy7mMiNCgX4b7vsc2HS+ZKYbHgCfcApJ
Sbn6Z6pnxETzw2ZoQphZWXk=
=tR29
-----END PGP SIGNATURE-----

--zCKi3GIZzVBPywwA--



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