[llvm-bugs] [Bug 40363] New: Test failure: constructor and deconstructor called unequal number of times

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 17 10:08:02 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40363

            Bug ID: 40363
           Summary: Test failure: constructor and deconstructor called
                    unequal number of times
           Product: clang
           Version: trunk
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stefanp at ca.ibm.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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.
-----

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190117/46f895f7/attachment.html>


More information about the llvm-bugs mailing list