<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Warning on vector push_back call of statically allocated object with programmer defined constructor or destructor"
   href="http://llvm.org/bugs/show_bug.cgi?id=20138">20138</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Warning on vector push_back call of statically allocated object with programmer defined constructor or destructor
          </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>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>linuxham@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm having a hard time determining if this is a STL bug or a clang false
positive, but the following code example at bottom causes this warning:

$ clang++ --analyze test.cpp
In file included from test.cpp:1:
In file included from
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../include/c++/4.8/vector:63:
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../include/c++/4.8/bits/stl_uninitialized.h:75:19:
warning: Forming reference to null
      pointer
                std::_Construct(std::__addressof(*__cur), *__first);
                                ^~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Code:

#include <vector>

class Foo
{
public:
//    ~Foo(){} // uncommenting causes warning
    Foo() {} // uncommenting causes warning
};

int main(void)
{
    std::vector<Foo> v;
    Foo f = Foo();
    v.push_back(f);

    return 0;
}

If both the programmer-defined constructor and destructor are commented out, no
warning is produced.  Filling the constructor and destructor with a simple
allocation and free of memory to an added private member still result in the
same warning.</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>