<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 --- - alpha.cplusplus.NewDeleteLeaks false-positive complicated conditions"
   href="http://llvm.org/bugs/show_bug.cgi?id=18394">18394</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>alpha.cplusplus.NewDeleteLeaks false-positive complicated conditions
          </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>Windows NT
          </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>anton.yartsev@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>Here is a minimal test that illustrates the problem. My attempts to simplify
the test led to the fact that the leak is not reported. The leak also
disappears if '-std=c++11' option is given to the compiler.

class Iter {
  public:
   int * _M_current;

   Iter(int * __i) : _M_current(__i) { }
   int * base() { return _M_current; }
};

bool operator==(Iter __lhs, Iter __rhs)
{ return __lhs.base() == __rhs.base(); }

class vector  {
public:

  int* _M_start;
  int* _M_finish;

  public:
    Iter begin() const
    { return Iter(_M_start); }

    Iter end() const
    { return Iter(_M_finish); }

    bool empty() { return begin() == end(); }
};

class raw_ostream {
public:
  char *OutBufEnd, *OutBufCur;

  int m() {
    if (OutBufCur >= OutBufEnd)
      return 1;

    return 0;
  }
};

raw_ostream *v;
vector *interestingSymbols;

class A {
public:
  bool f();
  ~A() {
    while (f()) {
      interestingSymbols->empty();
      interestingSymbols->empty();
      interestingSymbols->empty();
    }
  }
};

void error() {
  A *a = new A();
  delete a; // false-positive leak!

  v->m();
  v->m();
  v->m();
}

F:\llvm_COMMON\-VS_build-\Debug\bin>clang -cc1
-analyzer-checker=alpha.cplusplus.NewDeleteLeaks -analyze test.cpp 
test.cpp:59:3: warning: Potential leak of memory pointed to by 'a'
  delete a; // false-positive leak!
  ^~~~~~~~
1 warning generated.</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>