<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 22, 2017 at 12:01 PM, Keane, Erich via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wasn't sure whether to bring this up here, or to bring it up on the reflector, but I'm not sure if this is a compiler issue or a standards issue.  I read through the structured binding wording, and don't see anything one way or the other, and GCC7 and Clang trunk both allow the following:<br>
<br>
struct F {<br>
  unsigned a : 1;<br>
  unsigned b : 2;<br>
  unsigned c : 8;<br>
};<br>
<br>
int main() {<br>
  F f;<br>
  f.a = 0;<br>
  f.b = 1;<br>
  f.c = 4;<br>
<br>
  auto &b = f.b; // correctly errors on non-const ref to a bitfield<br>
<br>
  auto& [d,e,g] = f; // all are references to a bitfield<br></blockquote><div><br></div><div>The only reference here is an unnamed reference to `f`.  None of `d`, `e`, `g` is a reference.  `d` is another name for `f.a`, and similarly for `e` and `g`.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  d = 3; // Works, but warns about truncation<br>
  c = 3; // Works, no diagnostic<br>
}<br>
<br>
Is this intended?  Is this justified by the standard?<br></blockquote><div> </div><div>The behavior you describe appears correct (and unsurprising to me), apart from the assumption that these are references; they're "structured bindings", not references.</div><div><br></div><div>-- James</div><div><br></div></div></div></div>