Issue |
132044
|
Summary |
Bogus error when using `__reference_converts_from_temporary` in default template argument
|
Labels |
clang:frontend
|
Assignees |
|
Reporter |
aaronpuchert
|
We ran into this with an `std::function` (libstdc++ 13) returning an object with protected copy constructor. It boils down to this:
```c++
class X {
protected:
X(const X&);
};
static_assert(!__reference_converts_from_temporary(X, X));
template<typename A, typename B,
bool Dangle = __reference_converts_from_temporary(A, B)>
static void test();
using Result = decltype(test<X, X>());
```
produces:
```
bug.cpp:9:24: error: calling a protected constructor of class 'X'
9 | bool Dangle = __reference_converts_from_temporary(A, B)>
| ^
```
Replacing either `A` or `B` by `X` doesn't make the error go away. Interestingly, if we define `test`, for example with an empty body, and do a full instantiation, then the error appears if the instantiation is implicit, but not if it's explicit:
```c++
template<typename A, typename B,
bool Dangle = __reference_converts_from_temporary(A, B)>
static void test() {} // <-- Added an empty body.
template void test<X, X>(); // No error.
void f() {
test<X, X>(); // Error.
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs