On 01/03/24 15:38 -0500, Jason Merrill wrote:
On 3/1/24 14:24, Marek Polacek wrote:
+@smallexample
+template <typename T>
+[[gnu::no_dangling(std::is_reference_v<T>)]] int foo (T& t) @{
I think this function should return a reference.
The condition in the attribute can only ever be true if you call this
function with an explicit template argument list: foo<int&>(i). Is
that intentional?
And if T is non-const it can't be called with a temporary and so
dangling seems less of a problem for this function anyway, right?
Would it make more sense as something like this?
template <typename T>
[[gnu::no_dangling(std::is_lvalue_reference_v<T>)]]
decltype(auto) foo(T&& t) {
...
}
Or is this getting too complex/subtle for a simple example?