<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Test failure: constructor and deconstructor called unequal number of times"
   href="https://bugs.llvm.org/show_bug.cgi?id=40363">40363</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Test failure: constructor and deconstructor called unequal number of times
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stefanp@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following passed but now fails:

// -- test.cpp --
int ctor = 0;
int dtor = 0;

struct A {
  A() { ctor++; }
  ~A() { dtor++; }
  A(const A&) { ctor++; }
};

int main()
{
  ctor = dtor = 0;
  try {
    A a[100];
    const auto& x = [a](A b){return a[37];}((throw 47, a[59]));
  }
  catch (...) { }

  if (ctor != dtor)
    return 1;

  return 0;
}

Compile command:
clang++ -std=c++11 -o test test.cpp
./test

The main should return with 0 but it now returns 1.

Narrowed down the change and it seems that this change has caused/exposed the
issue.

-----
Author: Richard Smith
Date:   Fri Oct 19 19:01:34 2018 +0000

    PR24164, PR39336: init-captures are not distinct full-expressions.

    Rather, they are subexpressions of the enclosing lambda-expression, and
    any temporaries in them are destroyed at the end of that
    full-expression, or when the corresponding lambda-expression is
    destroyed if they are lifetime-extended.
-----</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>