Issue 146401
Summary Clang does not recognize hand-written buffer aliasing checks
Labels clang
Assignees
Reporter davidben
    Clang (and GCC) don't seem to recognize the `__fh_overlap` macro in https://godbolt.org/z/EqjKe716r as a buffer aliasing check.

The sample was adapted from https://github.com/jvoisin/fortify-headers/blob/master/include/string.h, which is reportedly used in Musl-based Linux distributions like Alpine.

In this case, since `r` was just allocated, the compiler should be able to reason that `r` cannot overlap with `a` and delete the `__fh_overlap` check. It's also important to be able to optimize this because `memcpy` is the usual pattern to load memory without tripping strict aliasing issues.

CC @andres-erbsen
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to