[LLVMbugs] [Bug 12028] New: Error for use of 'this' inside operator new should mention that operator new is implicitly static
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Feb 17 10:05:29 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12028
Bug #: 12028
Summary: Error for use of 'this' inside operator new should
mention that operator new is implicitly static
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jyasskin at google.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
$ cat test.cc
#include <new>
#include <stdlib.h>
class Foo {
public:
void* operator new(size_t s) {
void* result;
posix_memalign(&result, alignof(*this), s);
return result;
}
};
$ clang++ -std=c++11 -stdlib=libc++ -c test.cc
test.cc:8:38: error: invalid use of 'this' outside of a nonstatic member
function
posix_memalign(&result, alignof(*this), s);
^
1 error generated.
--------
Users may not realize that operator new is implicitly static, which would make
this error message confusing. Perhaps add a note: "operator new is implicitly
static"
The general error message isn't great either, with that triple negative: I'd
replace it with "'this' may only be used inside a nonstatic member function."
or, if more wording variations are ok, "'this' used inside static member
function".
--
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