<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 - clang-analyzer-cplusplus.NewDeleteLeaks false positive in C++17 mode only"
   href="https://bugs.llvm.org/show_bug.cgi?id=38176">38176</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-analyzer-cplusplus.NewDeleteLeaks false positive in C++17 mode only
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>florin@signbit.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>florin@helios$ cat unique.cc 
#include <cstdint>
#include <iostream>
#include <memory>

using Bar = uint64_t;

class Foo
{
public:
   explicit Foo(Bar bar) : bar(bar)
   {
   }

   const Bar& getBar()
   {
      return bar;
   }

private:
   Bar bar;
};

std::unique_ptr<Foo> fooMaker()
{
   Bar bar = {};

   return std::make_unique<Foo>(bar);
}

int main()
{
   return 0;
}

florin@helios:$ clang++-6.0 --analyze -Xanalyzer -analyzer-output=text
-std=c++14 -o unique.o   unique.cc                            
florin@helios:$ clang++-6.0 --analyze -Xanalyzer -analyzer-output=text
-std=c++17 -o unique.o   unique.cc                                              
florin@helios:$ /opt/llvm7/bin/clang++ --analyze -Xanalyzer
-analyzer-output=text -std=c++14 -o unique.o   unique.cc                        
florin@helios:$ /opt/llvm7/bin/clang++ --analyze -Xanalyzer
-analyzer-output=text -std=c++17 -o unique.o   unique.cc                        
Writing to last piece
unique.cc:27:4: warning: Potential leak of memory pointed to by field
'_M_head_impl'
   return std::make_unique<Foo>(bar);
   ^
unique.cc:27:11: note: Calling 'make_unique<Foo, unsigned long &>'
   return std::make_unique<Foo>(bar);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/unique_ptr.h:831:30:
note: Memory is allocated                                                       
    { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unique.cc:27:11: note: Returned allocated memory
   return std::make_unique<Foo>(bar);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
unique.cc:27:4: note: Potential leak of memory pointed to by field
'_M_head_impl'
   return std::make_unique<Foo>(bar);
   ^
1 warning generated.

-----------------------------------

This is with LLVM/Clang/Clang-Extra from trunk

llvm:
commit 2d2ebb317ec78069296276ca13a8461e4a27e6c6
Author: Andrea Di Biagio <<a href="mailto:Andrea_DiBiagio@sn.scee.net">Andrea_DiBiagio@sn.scee.net</a>>
    git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@337124">https://llvm.org/svn/llvm-project/llvm/trunk@337124</a>
91177308-0d34-0410-b5e6-96231b3b80d8

clang:
commit 27d1a66dffa9424bcdadc7cd52cf2ae019e49889
Author: Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>>
    git-svn-id: <a href="https://llvm.org/svn/llvm-project/cfe/trunk@337125">https://llvm.org/svn/llvm-project/cfe/trunk@337125</a>
91177308-0d34-0410-b5e6-96231b3b80d8</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>