Issue 169139
Summary [clang] Linker regression with lambda NTTP containing `consteval` function call
Labels clang
Assignees
Reporter k3DW
    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
```cpp
consteval int foo() {
    return 0;
}
template <auto fn>
void bar() {
    fn();
};
int main() {
 bar<[] { return foo(); }>();
}
```

The compile step succeeds, but the linking fails.

```none
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
```cpp
// etc
int main() {
    constexpr auto x = [] { return foo(); };
    bar<x>();
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to