[master] 777e03ba9 Disable strict aliasing with gcc where vtree.h is used

Dridi Boukelmoune dridi at varni.sh
Wed Mar 24 17:46:47 UTC 2021

On Wed, Mar 24, 2021 at 5:38 PM Nils Goroll <nils.goroll at uplex.de> wrote:
> commit 777e03ba9774bf635a972fa0561b50ff071908a9
> Author: Nils Goroll <nils.goroll at uplex.de>
> Date:   Wed Mar 24 18:25:24 2021 +0100
>     Disable strict aliasing with gcc where vtree.h is used
>     Please replace this commit with a better solution, if you have one.
>     e1ac59335f749b84280722425b355be344cc76e9 brought us the VRBT node
>     color encoded in the lower two bits of pointers.
>     gcc strict aliasing rules (as enabled with -O2 and higher) forbid
>     aliased lvalue access as in the following macro expanded code:
>     (*(uintptr_t *)&(parent)->entry.rbe_parent) &= ~((uintptr_t)3);

Is culprit code part of generated vtree.h functions? Or macros that we
may call directly?

>     Until we have a better solution, disable strict aliasing with gcc
>     for targets with any source file using vtree.h.
>     Note that we would want to limit -fno-strict-aliasing to individual
>     compliation units, but automake does not offer a simple and clean way
>     to achieve this:
>     https://www.gnu.org/software/automake/manual/html_node/Per_002dObject-Flags.html

If this is only in generated functions, we may be able to annotate
them with some kind of v_no_strict_aliasing_ attribute.

At first glance it looks like macros we call directly would be subject
to strict aliasing too.

More information about the varnish-commit mailing list