Re: I'm getting a "operation on xxx may be undefined" error in GCC 4.5.1 that I didn't use to get in 4.3.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Staffan Tjernstrom <stjernstrom@xxxxxxx> writes:

> #define rb_parent(r)   ((struct rb_node *)((r)->rb_parent_color & ~3))
> #define rb_color(r)   ((r)->rb_parent_color & 1)
> #define rb_is_red(r)   (!rb_color(r))
> #define rb_is_black(r) rb_color(r)
> #define rb_set_red(r)  do { (r)->rb_parent_color &= ~1; } while (0)
> #define rb_set_black(r)  do { (r)->rb_parent_color |= 1; } while (0)
> #define PHYSICAL_ADDR( r )  ((struct rb_node *)((size_t)(r)+(size_t)((r)?p_base:0)))
> #define RELATIVE_ADDR( r ) ((struct rb_node *)((size_t)(r)-(size_t)((r)?p_base:0)))
>
> static void rb_insert_color(struct rb_node *p_node, struct rb_root *p_root)
> {
>     struct rb_node *p_phys_node =  PHYSICAL_ADDR(p_node);
>     struct rb_node *p_parent, *p_phys_parent, *p_grandparent, *p_phys_grandparent;
>
>     while ( ( p_phys_parent = ( PHYSICAL_ADDR( p_parent = rb_parent( p_phys_node ) ) ) ) && rb_is_red( p_phys_parent ) )
>     {
>     }

The PHYSICAL_ADDR macro uses its argument twice.  You are passing an
assignment statement to PHYSICAL_ADDR.  The effect is that you are
assigning to p_parent twice in a single expression.  In C/C++ assigning
to the same variable more than once in a single expression is undefined
behaviour.  This warning is controlled by -Wsequence-point, q.v.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux