[LLVMbugs] [Bug 13481] New: Should not be able to declare operator new/delete as 'const'

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 30 10:43:07 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13481

             Bug #: 13481
           Summary: Should not be able to declare operator new/delete as
                    'const'
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jordan_rose at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The code below should be invalid, but it does not even warn, even under
-Weverything.

[class.free]p1: Any allocation function for a class T is a static member (even
if not explicitly declared static).

[class.free]p6: Any deallocation function for a class X is a static member
(even if not explicitly declared static).

[class.static.mfct]p2: ...A static member function shall not be declared const,
volatile, or const volatile.

(I discovered this when implementing an out-of-line operator new and got a type
mismatch due to a stray 'const'.)


---

char *buffer[1000];

struct A {
  void *operator new(unsigned long) const {
    return (void *)&buffer;
  }

  void operator delete(void *) const {
  }
};

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list