<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 --- - cmath: compile failure with custom fabs in std namespace"
href="http://llvm.org/bugs/show_bug.cgi?id=18176">18176</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>cmath: compile failure with custom fabs in std namespace
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>hhinnant@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>amdmi3@amdmi3.ru
</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=11687" name="attach_11687" title="Fix">attachment 11687</a> <a href="attachment.cgi?id=11687&action=edit" title="Fix">[details]</a></span>
Fix
When fabs() overload for custom type is added to std namespace, cmath won't
compile. Example code:
% cat test.cc
struct mytype {
};
namespace std {
mytype fabs(const mytype& a) {
return mytype();
}
}
#include <cmath>
int main() {
mytype a;
a = std::fabs(a);
return 0;
}
% clang++ test.cc
In file included from test.cc:10:
/usr/include/c++/v1/cmath:664:35: error: no matching function for call to
'fabs'
abs(double __x) _NOEXCEPT {return fabs(__x);}
^~~~
4.cc:5:9: note: candidate function not viable: no known conversion from
'double' to 'const mytype' for 1st argument
mytype fabs(const mytype& a) {
^
1 error generated.
Fix is attached. Similar fix may be needed for other functions from global
namespace.</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>