[all-commits] [llvm/llvm-project] 259eaa: [C++20] [Modules] Fix the duplicated static initia...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Wed Oct 30 02:27:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 259eaa6878ead1e2e7ef572a874dc3d885c1899b
      https://github.com/llvm/llvm-project/commit/259eaa6878ead1e2e7ef572a874dc3d885c1899b
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2024-10-30 (Wed, 30 Oct 2024)

  Changed paths:
    M clang/lib/CodeGen/CodeGenModule.cpp
    A clang/test/Modules/static-initializer.cppm

  Log Message:
  -----------
  [C++20] [Modules] Fix the duplicated static initializer problem (#114193)

Reproducer:

```
//--- a.cppm
export module a;
int func();
static int a = func();

//--- a.cpp
import a;
```

The `func()` should only execute once. However, before this patch we
will somehow import `static int a` from a.cppm incorrectly and
initialize that again.

This is super bad and can introduce serious runtime behaviors.

And also surprisingly, it looks like the root cause of the problem is
simply some oversight choosing APIs.



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