Re: Question about ECPGset_noind_null() and ECPGis_noind_null()

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Boszormenyi Zoltan <zb@cybertec.at>
Cc: Michael Meskes <meskes@postgresql.org>, pgsql-hackers@postgresql.org, Hans-Juergen Schoenig <hs@cybertec.at>
Date: 2009-11-19T19:33:47Z
Lists: pgsql-hackers
Boszormenyi Zoltan <zb@cybertec.at> writes:
>         for (; length > 0 && ptr[--length] == 0xff;);

> I suspect that GCC does the "--length" after checking
> "length > 0" and before checking the "ptr[...] == 0xff",
> but HP CC does it before checking "length > 0".

If it does, that is *unquestionably* a bug in HP's CC and should be
reported to them.  However, the code is sufficiently unreadable to
be worth rewriting anyhow.  Your suggestion is an improvement but
personally I'd plump for

	int	i;

	for (i = 0; i < length; i++)
		if (ptr[i] != 0xff)
			return false;
	return true;

			regards, tom lane