<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - libc++ appears to be missing overloads for some cmath functions (isfinite, etc.)"
href="https://bugs.llvm.org/show_bug.cgi?id=34566">34566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>libc++ appears to be missing overloads for some cmath functions (isfinite, etc.)
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dlj@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>In libc++, SFINAE is used to select different implementations of isfinite
(apparently, mostly for integral types). The C++ standard stipulates additional
overloads in [c.math], with an additional codicil for conversions of types
other than long double, double, and float.
In C++11:
"Moreover, there shall be additional overloads sufficient to ensure:
...
3. Otherwise, all arguments corresponding to double parameters are effectively
cast to float." (26.8p11)
In C++14:
"Moreover, there shall be additional overloads sufficient to ensure:
...
3. Otherwise, all arithmetic arguments corresponding to double parameters have
type float." (still 26.8p11)
It's not clear exactly what "arithmetic" means in the C++14 context, but libc++
uses the std::is_arithmetic type trait as part of the SFINAE overload selection
for std::isfinite. This might be in line with C++14 requirements, assuming that
satisfaction of std::is_arithmetic is the correct interpretation for the term
"arithmetic argument."
The upshot is that types which appear to be valid arguments to std::isfinite
under C++11 rules (through an implicit conversion operator) do not work in
libc++.
Example:
=====
#include <cmath>
struct MyFloat {
operator float() const { return 0.f; }
};
void checkfinite(void) {
MyFloat mf;
std::isfinite(0.0f); // OK
std::isfinite(0.0); // OK
std::isfinite(mf); // fails
}
=====
<a href="https://godbolt.org/g/xX4rMb">https://godbolt.org/g/xX4rMb</a>
The fix for the SFINAE code could simply be additionally allow a check for
whether the argument is convertible to float.</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>