NoQ added a comment.

In D96215#2548492 <https://reviews.llvm.org/D96215#2548492>, @aaron.ballman 
wrote:

> Should structured bindings be treated similarly as well (not necessarily as 
> part of this patch)?

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.


Repository:
  rCTE Clang Tools Extra

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
  • [PATCH] D96215: [clang-tid... Artem Dergachev via Phabricator via cfe-commits

Reply via email to