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

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 13:05:34 PDT 2023


mstorsjo added a comment.

In D148723#4381414 <https://reviews.llvm.org/D148723#4381414>, @serge-sans-paille wrote:

> 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?

Still reproduces at d81ce04587c006b6731198956c522c93d0df1050 <https://reviews.llvm.org/rGd81ce04587c006b6731198956c522c93d0df1050> (and the commit you referenced on irc). Did you use the exact command line from the repro? Note that it uses a 32 bit target triple - with a 64 bit target, you need to change the definition of `size_t`.


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