<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 --- - The return type of std::pow(std::complex<float>, int) should be std::complex<float>"
href="http://llvm.org/bugs/show_bug.cgi?id=20293">20293</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The return type of std::pow(std::complex<float>, int) should be std::complex<float>
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kariya_mitsuru@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>With libc++, the return type of std::pow(std::complex<float>, int) is
std::complex<double>.
However, in C++03 mode, the return type of std::pow(std::complex<float>, int)
should be
std::complex<float>.
According to C++03 standard 26.2.7[lib.complex.value.ops], std::pow have an
overload
function template "template<class T> std::complex<T> std::pow(const
std::complex<T>&, int)".
So I think that the return type of std::pow(std::complex<float>, int) should be
std::complex<float> in C++03 mode.
The sample code below can show whether the return type is std::complex<float>.
===========================================================================================
#include <iostream>
#include <typeinfo>
#include <complex>
int main()
{
std::cout << std::boolalpha
<< (typeid(std::pow(std::complex<float>(1), 1)) ==
typeid(std::complex<float>))
<< std::endl;
}
===========================================================================================
cf. <a href="http://melpon.org/wandbox/permlink/GT7RQffV1BXEOImC">http://melpon.org/wandbox/permlink/GT7RQffV1BXEOImC</a>
Additionally, in C++03, the 2nd argument of std::pow can cause implicit
conversions.
(Because it is the trivial int type.)
Therefore, I think that the sample code below should be compiled successfully
in C++03 mode.
===========================================================================================
#include <complex>
struct S {
operator int() { return 1; }
};
int main()
{
std::complex<float> d = std::pow(std::complex<float>(0), S());
}
===========================================================================================
cf. <a href="http://melpon.org/wandbox/permlink/G0CEVjhnaTEMfbNs">http://melpon.org/wandbox/permlink/G0CEVjhnaTEMfbNs</a>
Note that the 2nd sample should be compiled successfully with double and long
double too.</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>