<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 - diagnostic attributes (unavailable, diagnose_if, etc.) do not trigger on "operator delete""
   href="https://bugs.llvm.org/show_bug.cgi?id=34816">34816</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>diagnostic attributes (unavailable, diagnose_if, etc.) do not trigger on "operator delete"
          </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>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>jbroman@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>e.g.

// foo.cc
struct Undeletable {
  static void operator delete(void*) __attribute__((unavailable("can't touch
this"))) {}
};

void DeleteUndeletable(Undeletable* u) { delete u; }

$ clang++ --version
clang version 6.0.0 (trunk 313786)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /src/chromium/src/third_party/llvm-build/Release+Asserts/bin
$ clang++ -c foo.cc
$ echo $?
0

I would expect a compile error (similar for diagnose_if). I can get one if I
compile with exceptions on (i.e. no -fno-exceptions) and I use "operator new"
(presumably arising from the call generated in the case of an exception being
thrown), but it points at the use of "new" and not the use of "delete".

foo.cc:36:25: error: 'operator delete' is unavailable: can't touch this
void NewUndeletable() { new Undeletable; }
                        ^
foo.cc:31:15: note: 'operator delete' has been explicitly marked unavailable
here
  static void operator delete(void*) __attribute__((unavailable("can't touch
this"))) {
              ^
1 error 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>