[all-commits] [llvm/llvm-project] 863b2e: [C++20] [Modules] Fix the duplicated static initia...
Chuanqi Xu via All-commits
all-commits at lists.llvm.org
Mon Nov 18 08:00:35 PST 2024
Branch: refs/heads/release/19.x
Home: https://github.com/llvm/llvm-project
Commit: 863b2e599016ada8b2f4cc4d8c59eb7d8f61ee7f
https://github.com/llvm/llvm-project/commit/863b2e599016ada8b2f4cc4d8c59eb7d8f61ee7f
Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
Date: 2024-11-15 (Fri, 15 Nov 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.
(cherry picked from commit 259eaa6878ead1e2e7ef572a874dc3d885c1899b)
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