<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 - Delete called in virtual destructor"
   href="https://bugs.llvm.org/show_bug.cgi?id=35517">35517</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Delete called in virtual destructor
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>moko@design.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code produces link error with all available to us clang versions.
It compiles when destructor is not virtual. Note that there is no "new"
operator calls, only "delete" is called. The code also compiles with gcc
starting with version 6.1.

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

/tmp/example-d524df.o: In function `operator delete(void*)':
23 : <source>:23: undefined reference to `no_such_methood()'
clang-5.0: error: linker command failed with exit code 1 (use -v to see
invocation)

--------------------------------------
URL to play with the code: <a href="https://godbolt.org/g/1ifDyg">https://godbolt.org/g/1ifDyg</a>

--------------------------------------
#include <new>
#include <cstdlib>

#pragma clang diagnostic ignored "-Winline-new-delete"

 void no_such_methood();
 //void no_such_methood(){asm ("nop");};

inline void* operator new(size_t size) throw(std::bad_alloc)
{
  no_such_methood();
  return malloc(size);
}

inline void* operator new[](size_t size) throw(std::bad_alloc)
{
  no_such_methood();
  return malloc(size);
}

inline void operator delete(void* ptr) throw()
{
  no_such_methood();
  free(ptr);
}

inline void operator delete[](void* ptr) throw()
{
  no_such_methood();
  free(ptr);
}

struct MyStructBase
{
     virtual ~MyStructBase()
     {
  }
};

struct MyStruct : MyStructBase
{
};

int main(void)
{
  MyStruct ss;
  return 0;


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

That is why we use the such code in our project:
<a href="https://stackoverflow.com/questions/18365804/is-it-possible-to-completely-disable-the-default-c-new-operator">https://stackoverflow.com/questions/18365804/is-it-possible-to-completely-disable-the-default-c-new-operator</a>

--------------------------------------
Possibly it compiles in gcc after this change:

<a href="http://patchwork.ozlabs.org/patch/604210/">http://patchwork.ozlabs.org/patch/604210/</a>

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