[Bug libstdc++/90638] Wrong results of pow(complex<T> , T1) function when the T1 type differs from T and from int

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jun 7 13:57:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90638

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As a workaround for C++03, you can either change the type of lp1 and lp2 to
double, or cast them when used:

  std::cout<<' '<<pow(var0, (double) lp1)
           <<' '<<pow(var0,  (double) lp2)
           <<'\n'<<'\n';

  std::cout<<' '<<pow(vard0, (long double) lp1)
           <<' '<<pow(vard0, (long double) lp2)
           <<'\n'<<'\n';

This will prevent the pow(const complex<T>&, int) overload being used.


More information about the Gcc-bugs mailing list