[PATCH] D148723: [clang] Restrict Inline Builtin to non-static, non-odr linkage

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 09:43:01 PDT 2023


serge-sans-paille added a comment.

In D148723#4380165 <https://reviews.llvm.org/D148723#4380165>, @mstorsjo wrote:

> This causes failed asserts with `_FORTIFY_SOURCE` with the mingw-w64 headers. Here's a reduced reproducer:
>
>   $ cat reduced.c
>   typedef unsigned int size_t;
>   
>   void *memcpy(void *_Dst, const void *_Src, size_t _Size);
>   
>   extern __inline__ __attribute__((__always_inline__, __gnu_inline__)) __attribute__((__artificial__)) 
>   void *memcpy(void *__dst, const void *__src, size_t __n) 
>   {
>     return __builtin___memcpy_chk(__dst, __src, __n, __builtin_object_size((__dst), ((0) > 0) && (2 > 1))); 
>   } 
>   
>   void *memcpy(void *_Dst, const void *_Src, size_t _Size);
>   
>   char *a, *b;
>   void func(void) {
>       memcpy(a, b, 42);
>   }
>   $ clang -target i686-w64-mingw32 -c reduced.c -O2
>   clang: ../../clang/lib/AST/Decl.cpp:3763: bool clang::FunctionDecl::isInlineDefinitionExternallyVisible() const: Assertion `(doesThisDeclarationHaveABody() || willHaveBody() || hasAttr<AliasAttr>()) && "Must be a function definition"' failed.
>
> Here, the second declaration of the regular extern version of the function is what is triggering the issue.
>
> Can we revert this to unbreak my builds until we have a fix?

I can't reproduce locally. Can you check your reproducer on current main?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148723/new/

https://reviews.llvm.org/D148723



More information about the cfe-commits mailing list