https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99623
--- Comment #9 from Sebastiano Vigna <sebastiano.vigna at unimi dot it> --- Finally solved: the problematic statement if (h == NULL) h = (struct prb_node *)&tree->prb_root; should just be if (h == NULL) h = tree->prb_root->prb_link[0]; The position in memory of the two pointers is the same, but the second access has the right type. I guess the GNU libavl author wanted to save an indirection, but did not realize the possible dangers. For the user, this behavior of the optimizer remains very confusing tho.