Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jul 2013 09:13:12 +0100
From:      David Chisnall <theraven@FreeBSD.org>
To:        Tim Kientzle <tim@kientzle.com>
Cc:        dt71@gmx.com, freebsd-current@FreeBSD.org
Subject:   Re: another -Wunsequenced topic
Message-ID:  <374FC203-F5FB-4C7C-84D3-76A7AD507D90@FreeBSD.org>
In-Reply-To: <6AC1186D-3D9C-4B7A-B5E4-4EA9CB120517@kientzle.com>
References:  <51CEEC34.2010308@gmx.com> <51D03D27.3020100@gmx.com> <51DAA5FE.4040505@gmx.com> <6AC1186D-3D9C-4B7A-B5E4-4EA9CB120517@kientzle.com>

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

--Apple-Mail=_5A46FA65-E6BA-4461-97EE-481C88DB19C4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 9 Jul 2013, at 05:40, Tim Kientzle <tim@kientzle.com> wrote:

> However, this does have an implicit redundant store,
> so changing it to
>=20
>    ptr =3D func(ptr + 1);
>=20
> is still a good idea, just not for the reason Clang was claiming.

If the compiler can tell that ptr has not escaped, then it will elide =
the redundant store (typically, it will be gone as long as ptr is a =
local and its address has not been passed out of the function), so there =
should be no change to the generated code.

However, I still agree that it is good style, because if I read the =
original code I would be left wondering what the original programmer =
expected the incremented value of ptr++ to be visible to and suspect a =
more subtle error. =20

David


--Apple-Mail=_5A46FA65-E6BA-4461-97EE-481C88DB19C4
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.18 (Darwin)
Comment: GPGTools - http://gpgtools.org

iQIcBAEBAgAGBQJR28YYAAoJEKx65DEEsqIdj6gP/jdC6pgahOjH/rP+cKoSuo2p
Z5S3BcaFn7d0VNeqFxN29lxfqjvnqwXLcZg2G/p7u4Vkn78sXwUNqX9XjIk5QmVY
5LQ1qez6QLrpPKcmwC3yHaKuiPm0yThy4I/v/sRmEXgkFYw4JMuvOsfq0aWO4guj
h7CtRXHkvxH7xx5RY4miWnow76W39IUSZFbidSWYmDydHrzIy/zgBzlQgnWg7NWI
GGa6ESM7L7/1EQ61jSSBGxlW39Rfw8qQsBsrpg61rQs/7u/ZpKNpS9x3Cqy7npww
eqwCePVa6DeVMYJgd3Lx8TNOR7jND7qjw4GcsLBk5zXK5lkpyK1tVc1AlL4eiEJJ
wPiq91SIvwJgoNUT2qGYhlAxrDCqtkucPK46MG2hOD+tAv0FCCZKTcF/VtjA12uP
eQnPDwyAIDHDGWJVBuRMny7mMv4jn+TpHIe1D+5NNYkQw8kPUbqCddsRgj3hJfaA
og9hoV3EhKEbJTS574XjPw7AQaJrosJR8sRTKcm/fjMbEn7xylw0B0CU+NK/eH9s
lQvBWRPwldzYONRq6FCMyaKMSD8U1ZsMQMg82hjN53e16PYU8dZGrkrxFU3OhBWf
yFxeqWM5ez0x3YK/3lG7lqgDqzYm3m3IzdLfaogz/4ksdj4uzdObueCfnqVJCRBz
2dfonQ6HcbHM2B5H81/j
=qg4B
-----END PGP SIGNATURE-----

--Apple-Mail=_5A46FA65-E6BA-4461-97EE-481C88DB19C4--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?374FC203-F5FB-4C7C-84D3-76A7AD507D90>