Date: Wed, 6 Nov 2002 18:57:26 +0200 From: Peter Pentchev <roam@ringlet.net> To: Marc Olzheim <marcolz@stack.nl> Cc: hackers@FreeBSD.ORG Subject: Re: /usr/src/ed/bin/re.c:99 Message-ID: <20021106165726.GU369@straylight.oblivion.bg> In-Reply-To: <20021106164653.GA95733@stack.nl> References: <20021106164653.GA95733@stack.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Wed, Nov 06, 2002 at 05:46:53PM +0100, Marc Olzheim wrote:
> ..
> if ((nd = parse_char_class(++nd)) == NULL) {
> ..
>
> Hmmm... is this legal ?
>
> http://www.eskimo.com/~scs/C-faq/q3.1.html seems to tell otherwise...
In this particular case, the value of 'nd' is not *used* anywhere in the
expression. The fact that 'nd' is *assigned to* is not influenced in
any way by the change of its value.
It is absolutely certain that the compiler will put the code calculating
the value of the argument to parse_char_class() before the code actually
invoking parse_char_class(), and that it will also place the code
invoking parse_char_class() before the code which assigns the return
value to 'nd'.. thus, it is absolutely certain that 'nd' will be
assigned the correct value.
Once again: the main reason why q3.1 is not relevant here is the fact
that q3.1 deals with expressions where the value of 'nd' is used; here,
the left side of the assignment does not 'use' the value, it *changes*
it :)
Hope that helps.
G'luck,
Peter
--
Peter Pentchev roam@ringlet.net roam@FreeBSD.org
PGP key: http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553
I've heard that this sentence is a rumor.
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE9yUn27Ri2jRYZRVMRAqybAJwKf6/wkjkB5mizVZYnpYnLLPpoPwCgnMqr
t0q1XtZ+XDpp7b1rKzVTjbw=
=QSy2
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021106165726.GU369>
