njames93 added a comment.

In D96215#2550227 <https://reviews.llvm.org/D96215#2550227>, @NoQ wrote:

> Umm, looks like we're both missing the elephant in the room: passing a 
> variable into a function by reference.
>
>   int &hidden_reference(int &x) {
>     return x;
>   }
>   
>   void test_hidden_reference() {
>     int x = 0;
>     int &y = hidden_reference(x);
>     for (; x < 10; ++y) { // Warns ¯\_(ツ)_/¯
>     }
>   }
>
> With this taken care of, I hope structured bindings will be handled 
> automatically because whatever's unwrapped couldn't have obtained a reference 
> to our local variable without going through a function first (eg., the 
> constructor). Unless there's some aggregate magic going on... but in this 
> case, again, we have to take care of aggregate magic and structured bindings 
> aren't at fault.

Just my $0.02, We shouldn't worry too much about pathological cases like that. 
I imagine that code would almost never appear in the wild. And for cases where 
you don't have access to definition for `hidden_reference `, there's not much 
that can be done anyway.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96215/new/

https://reviews.llvm.org/D96215

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to