C and side-effects

From: Cesar Eduardo Barros (cesarb@web4u.com.br)
Date: Wed May 03 2000 - 16:15:40 EST


        while ((mm->swap_cnt << 2 * (i + 1) < max_cnt) && i++ < 10)
                /* nothing */;

I'm not that good at C, mas aren't expressions with side-effects ill-defined?
How can we be sure (short of tracking the gcc mailing lists) that i will be
incremented after the left part of the test?

I'd suggest
        while (mm->swap_cnt << 2 * (i + 1) < max_cnt)
        {
                int j = i++;
                if (!(j < 10))
                        break;
        }

-- 
Cesar Eduardo Barros
cesarb@web4u.com.br
cesarb@dcc.ufrj.br

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:13 EST