<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Can't build application with redefined new/delete and ASAN (multiple definition of "operator new")"
href="http://llvm.org/bugs/show_bug.cgi?id=19660">19660</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Can't build application with redefined new/delete and ASAN (multiple definition of "operator new")
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>altsysrq@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=12480" name="attach_12480" title="Test file with redefined "operator new"">attachment 12480</a> <a href="attachment.cgi?id=12480&action=edit" title="Test file with redefined "operator new"">[details]</a></span>
Test file with redefined "operator new"
Following test code fails to build with enabled ASAN:
$ cat custom_new.cpp
#include <stdexcept>
void * operator new(std::size_t)
{
throw std::bad_alloc();
}
int main()
{
}
$ clang++ -Wall -O0 -fsanitize=address -std=c++11 custom_new.cpp
/tmp/custom_new-015fb3.o: In function `operator new(unsigned long)':
custom_new.cpp:(.text+0x0): multiple definition of `operator new(unsigned
long)'
/usr/bin/../lib/clang/3.4/lib/linux/libclang_rt.asan-x86_64.a(asan_new_delete.o):(.text+0x10):
first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Without replacing new operator program builds and works with ASAN enabled.
Same file builds with enabled ASAN using GCC 4.8:
$ g++ -Wall -O0 -fsanitize=address -std=c++11 custom_new.cpp
$ clang++ --version
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
On Ubuntu 14.04.</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>