Date: Sat, 22 Feb 1997 22:45:03 +0100 From: Eivind Eklund <eivind@dimaga.com> To: Alex Belits <abelits@phobos.illtel.denver.co.us> Cc: audit-bin@FreeBSD.ORG, FreeBSD-hackers@FreeBSD.ORG Subject: Re: hmm Message-ID: <3.0.32.19970222224502.00ac1650@dimaga.com>
next in thread | raw e-mail | index | archive | help
[Alex Belits] >>> with p="" >>> *p != '\0' && p[strlen(p) - 1] == '[' _still_ will read a byte p[-1]. [Terry Lambert] >> What? >> >> IF p = "" >> THEN *p = '\0' >> >> by definition of ""... [Alex Belits] >but p[strlen(p) - 1] will be p[-1] >Optimization done by compiler may skip it, but depending on that will be >rather dangerous. && is defined as short-circuiting. If *p == '\0' the evaluation of p[strlen(p) - 1] == '[' is guaranteed to be skipped. Re-read your book on C :) Eivind Eklund perhaps@yes.no http://maybe.yes.no/perhaps/ eivind@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.32.19970222224502.00ac1650>