[llvm-bugs] [Bug 44376] New: Iterator-based for-loop destroys the iterated object before the loop ends

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 24 12:58:58 PST 2019


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

            Bug ID: 44376
           Summary: Iterator-based for-loop destroys the iterated object
                    before the loop ends
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yuri at tsoft.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 22963
  --> https://bugs.llvm.org/attachment.cgi?id=22963&action=edit
clang-testcase-for-loop-object-destroyed.cpp

The attached testcase creates std::vector<int>, wraps it into
std::unique_ptr<std::vector<int>>, and iterates based on it.

std::unique_ptr<std::vector<int>> gets destroyed before the first iteration,
therefore invalidating the iterators.

All temporary objects involved in "for (auto it :
someExpressionWithTempObjects()) { }" should be destroyed after the loop ends.


clang version 9.0.0 on FreeBSD

-- 
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/20191224/b6db5c57/attachment.html>


More information about the llvm-bugs mailing list