-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules
Description
Given the following set of translation units:
export module a;
export int __attribute__((always_inline)) foo() {
static int x;
return ++x;
}
import a;
int test1() { return foo(); }
import a;
int test2() { return foo(); }
#include <iostream>
int test1();
int test2();
int main() {
std::cout << test1();
std::cout << test2();
}
The program outputs 11
instead of the expected result 12
. Function test1
and function test2
access distinct static int x
objects which are mistakenly inlined into their bodies.
Up to clang 17.0.1, this behavior can happen even if foo
is not marked with always_inline
(with optimizations enabled). Seems like this problem is partially fixed by PR #71031 , but the PR misses always_inline
functions.
Metadata
Metadata
Assignees
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules