This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/61795] [C++11] return type of std::pow(std::complex<float>, int) should be std::complex<double>
- From: "kariya_mitsuru at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 Jul 2014 03:40:58 +0000
- Subject: [Bug libstdc++/61795] [C++11] return type of std::pow(std::complex<float>, int) should be std::complex<double>
- Auto-submitted: auto-generated
- References: <bug-61795-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61795
--- Comment #2 from Mitsuru Kariya <kariya_mitsuru at hotmail dot com> ---
I think that this behaviour is caused by r201253 (for PR57974, Comment 11).
DR844 was fixed by r136694 but reverted by r201253.
diff r135878 r136694
https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/complex?r1=135878&r2=136694
diff r199924 r201253
https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/complex?r1=199924&r2=201253
Moreover, I think that I mistook.
> Note that this problem does not occur in std::complex<double> and
> std::complex<long double> because there is no difference between
> C++03 and C++11.
This is not true.
In C++03, the 2nd argument of std::pow can cause implicit conversions.
(Because it is the trivial int type.)
However, I believe that it should cause no implicit conversion in C++11.
(I think so from C++11 standard text quoted above.)
Therefore, I think that the sample code below should be compiled successfully
in C++03 mode but should cause compilation error in C++11 mode.
===================================================================
#include <complex>
struct S {
operator int() { return 1; }
};
int main()
{
std::complex<double> d = std::pow(std::complex<double>(0), S());
}
===================================================================