http://llvm.org/bugs/show_bug.cgi?id=20293
Bug ID: 20293
Summary: The return type of std::pow(std::complex<float>, int)
should be std::complex<float>
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
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. http://melpon.org/wandbox/permlink/GT7RQffV1BXEOImC
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. http://melpon.org/wandbox/permlink/G0CEVjhnaTEMfbNs
Note that the 2nd sample should be compiled successfully with double and long
double too.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs