summaryrefslogtreecommitdiff
path: root/clang/test/Modules/static-initializer.cppm
AgeCommit message (Collapse)Author
2024-10-30[C++20] [Modules] Fix the duplicated static initializer problem (#114193)Chuanqi Xu
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.