[clang] [clang] Do not infer lifetimebound for functions with void return type (PR #131997)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 19 09:06:11 PDT 2025
ilya-biryukov wrote:
@usx95 I struggled to come up with a reproducer and couldn't understand why at first.
I think we infer the attribute **after** we check for this error. This is obviously something we need to fix, but you can get a reproducer like this:
https://gcc.godbolt.org/z/e66MY1nn5
```cpp
// RUN: %clang_cc1 -std=c++20 -verify %s
namespace std {
template <class T>
constexpr const T& as_const(T&) noexcept;
// We need two declarations to see the error for some reason *shrug*
template <class T> void as_const(const T&&) noexcept = delete;
template <class T> void as_const(const T&&) noexcept;
}
namespace GH126231 {
void test() {
// Instantiate the overload returning `void` to trigger an error.
int a = 1;
std::as_const(a);
}
}
```
https://github.com/llvm/llvm-project/pull/131997
More information about the cfe-commits
mailing list