sbitmap cleanups
grahams
grahams@rcp.co.uk
Mon Apr 10 11:57:00 GMT 2000
Richard
Richard Kenner wrote:
>
> > ! for (ap = a->elms, bp = b->elms, i = 0; i < a->size; i++)
> > ! if ((*ap++ | *bp++) != *bp)
> > ! return 0;
>
> Uh, I didn't notice any sequence points... you could just put the
> increments up beside the `i++'.
>
> Sure, but it's usually more idiomatic to do it at the reference like that.
The result of evaluating ((*ap++ | *bp++) != *bp) is not well defined.
It can be evaluated may different ways all equally valid. The problem is the
use of *bp++ and *bp in the same expression without an intervening sequence
point.
Perhaps it should be written as follows which matches the style of many of
the other routines.
for (ap = a->elms, bp = b->elms, i = 0; i < a->size; i++)
{
SBITMAP_ELT_TYPE tmp = *bp;
if ((*ap++ | *bp++) != tmp)
return 0;
}
Graham
More information about the Gcc-patches
mailing list