[llvm-bugs] [Bug 25740] New: attribute visibility problems when using operator overloading (new/delete)
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Dec 4 07:05:12 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25740
Bug ID: 25740
Summary: attribute visibility problems when using operator
overloading (new/delete)
Product: clang
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: kaptain-blaubaer at web.de
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
Using this example:
#include <cstdio>
#include <cstdlib>
// replacement of a minimal set of functions:
__attribute__((visibility("hidden")))
void* operator new(std::size_t sz) {
std::printf("global op new called, size = %zu\n",sz);
return std::malloc(sz);
}
void operator delete(void* ptr)
{
std::puts("global op delete called");
std::free(ptr);
}
int main() {
int* p1 = new int;
delete p1;
int* p2 = new int[10]; // guaranteed to call the replacement in C++11
delete[] p2;
}
Compilation fails using CLang 3.7.0 and Clang 3.8.0 (trunk):
$ clang x.cpp -lstdc++
x.cpp:4:16: error: visibility does not match previous declaration
__attribute__((visibility("hidden")))
^
note: previous attribute is here
x.cpp:5:7: warning: 'operator new' is missing exception specification
'throw(std::bad_alloc)'
void* operator new(std::size_t sz) {
^
throw(std::bad_alloc)
x.cpp:9:6: warning: 'operator delete' is missing exception specification
'throw()'
void operator delete(void* ptr)
^
throw()
2 warnings and 1 error generated.
But Succeeds using Clang 3.6.2 and 3.5.0:
$ clang x.cpp -lstdc++
x.cpp:5:7: warning: 'operator new' is missing exception specification
'throw(std::bad_alloc)'
void* operator new(std::size_t sz) {
^
throw(std::bad_alloc)
x.cpp:9:6: warning: 'operator delete' is missing exception specification
'throw()'
void operator delete(void* ptr)
^
throw()
2 warnings 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/20151204/c486aa3d/attachment.html>
More information about the llvm-bugs
mailing list