title: Why does clang++ report a structured binding with "value stored to '...' during its initialization is never read"?
body: <p>I have the following test case:</p>
  
  <pre><code>testcase("[room] exits") {
      auto [center, east, north, south, west] = make_test_rooms();
  
      check_eq(center-&gt;east(), east);
      check_eq(center-&gt;north(), north);
      check_eq(center-&gt;south(), south);
      check_eq(center-&gt;west(), west + 1);
  }
  </code></pre>
  
  <p>When I compile it, clang++ (clang version 5.0.1 (tags/RELEASE_501/final)) reports:</p>
  
  <pre><code>room.cpp:52:7: note: Value stored to '[center, east, north, south, west]' during its initialization is never read
  </code></pre>
  
  <p>In the code above, <code>testcase</code> and <code>check_eq</code> are macros defined for <a href="https://github.com/onqtam/doctest" rel="nofollow noreferrer">the doctest unit testing package</a> that expand to <code>DOCTEST_TEST_CASE()</code> (some kind of self-registering variable+function pair) and <code>DOCTEST_CHECK_EQ</code> (basically, "assert a == b", with magic handling).</p>
  
  <p>I know this code is being executed, since the <code>west + 1</code> is a deliberately-introduced error. When I run my tests, I get a failure message like this one:</p>
  
  <pre><code>===============================================================================
  /.../room.cpp(51)
  TEST CASE:  [room] exits
  
  /.../room.cpp(57) ERROR!
    CHECK_EQ( center-&gt;west(), west + 1 )
  with expansion:
    CHECK_EQ( 0x00007fd6f1d011a0, 0x00007fd6f1d011f8 )
  </code></pre>
  
  <p>As far as I can see, I am using all of the values in the structured binding: <code>center</code> appears on the left of my checks, and <code>north, south, east, west</code> appear on the right. Why is clang++ reporting something as "never read"? </p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is code that reproduces the issue. I run this command line (taken from the output of <code>make VERBOSE=1</code> and reduced):</p>
  
  <pre><code>$ /opt/local/bin/cmake -E __run_co_compile --tidy=/opt/local/bin/clang-tidy --source=test.cpp -- /opt/local/bin/clang++  -g -std=gnu++1z -o test.cpp.o -c test.cpp
  /Users/austin/Code/agb/test.cpp:12:7: warning: Value stored to '[a, b, c]' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
          auto [a,b,c] = foo();
               ^
  /Users/austin/Code/agb/test.cpp:12:7: note: Value stored to '[a, b, c]' during its initialization is never read
  </code></pre>
  
  <p>I used this source file as <code>test.cpp</code>:</p>
  
  <pre><code>#include &lt;tuple&gt;
  
  static std::tuple&lt;int, int, int&gt;
  foo()
  {
      return {1,2,3};
  }
  
  bool
  test()
  {
      auto [a,b,c] = foo();
  
      return a&lt;b and b&lt;c;
  }
  </code></pre>