[all-commits] [llvm/llvm-project] f5e74f: [clang][WebAssembly] Don't register this-returning...

RobinTF via All-commits all-commits at lists.llvm.org
Tue Sep 29 12:36:45 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f5e74feac05ec1182c77874e8704728688a9174d
      https://github.com/llvm/llvm-project/commit/f5e74feac05ec1182c77874e8704728688a9174d
  Author: RobinTF <textorr at cs.uni-freiburg.de>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/CodeGen/CGExpr.cpp
    M clang/test/CodeGenCXX/static-destructor.cpp

  Log Message:
  -----------
  [clang][WebAssembly] Don't register this-returning destructors of reference temporaries directly with `__cxa_atexit` (#226619)

Under ABIs whose destructors return `this` (ARM, WebAssembly), a
destructor can only be registered directly (with `__cxa_atexit` etc.) if
the target tolerates the resulting function type mismatch. Clang already
checks this for global variables and registers a helper function
instead, but temporaries that are lifetime-extended by a reference with
static or thread storage duration always had their destructor registered
directly. On WebAssembly, which does not tolerate the mismatch, this
traps with "function signature mismatch" when the exit-time destructors
run. This PR changes the if condition to use the destroy helper that is
already used for arrays if the destructor cannot be registered directly.

Previously the following code would result in this:

```cpp
#include <cstdio>
struct B { B() {} ~B() { std::puts("~B"); } };
const B& b = B();
int main() {}
```

```
$ em++ -O2 -sEXIT_RUNTIME=1 repro.cpp -o repro.js && node repro.js
RuntimeError: function signature mismatch
<node stack trace>
```

with this patch applied it simply prints "~B".

Fixes #45221

Assisted-by: Claude Opus 5.5



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list