In C, if a variable is a signed integer, then the binary bitwise operator >>
on it is implementation dependent (you shouldn't rely on it). See this post as Gaurav suggested in comments.
In your exmaple, pl->size
is (guessing!) a signed integer, and you do (pl->size >> 1)
, so you apply a binary bitwise operator >>
on pl->size
variable. Clang tries to warn you about an implementation defined behavior, so you can fix your code.
Use division and multiplication on signed integers, which is well defined. The compiler should optimize the code anyway.
new_elem = realloc(pl->elem, (pl->size + (pl->size/2)) * sizeof(Elem));