-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Open
Copy link
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.constevalC++20 constevalC++20 constevalmiscompilationregression:21Regression in 21 releaseRegression in 21 release
Description
This following code worked in Clang 20, but no longer works in Clang 21. It also works in MSVC and GCC. I'm wondering whether this is a regression. https://godbolt.org/z/aYTTorW3o
consteval int foo() {
return 0;
}
template <auto fn>
void bar() {
fn();
};
int main() {
bar<[] { return foo(); }>();
}The compile step succeeds, but the linking fails.
ASM generation compiler returned: 0
/opt/compiler-explorer/gcc-15.2.0/lib/gcc/x86_64-linux-gnu/15.2.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-a45c6a.o: in function `main::$_0::operator()() const':
<source>:9:(.text+0x3d): undefined reference to `foo()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Execution build compiler returned: 1
Build failed
Note that this code works fine when the lambda is not a temporary. https://godbolt.org/z/6xPPczena
// etc
int main() {
constexpr auto x = [] { return foo(); };
bar<x>();
}Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.constevalC++20 constevalC++20 constevalmiscompilationregression:21Regression in 21 releaseRegression in 21 release