[llvm-bugs] [Bug 34816] New: diagnostic attributes (unavailable, diagnose_if, etc.) do not trigger on "operator delete"

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 3 06:51:24 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34816

            Bug ID: 34816
           Summary: diagnostic attributes (unavailable, diagnose_if, etc.)
                    do not trigger on "operator delete"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jbroman at chromium.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171003/eeec2802/attachment.html>


More information about the llvm-bugs mailing list