[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 01:21:56 PDT 2023


mstorsjo added a comment.

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?


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