-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!
Description
The Standard states that pow(complex<float>, int) should treat both arguments as complex<double>, indicating that it should also return complex<double>. Instead it returns a complex<float>.
> type test.cpp
#include <complex>
#include <type_traits>
using namespace std;
int main()
{
static_assert(
is_same_v<
complex<double>,
decltype(pow(complex<float>{}, int{}))
>,
"pow(complex<float>, int) should return complex<double>"
);
}
> cl /EHsc /nologo /W4 /std:c++17 test.cpp
test.cpp
test.cpp(12): error C2338: pow(complex<float>, int) should return complex<double>
WG21-N4835 [cmplx.over]/3 states:
Function template
powshall have additional overloads sufficient to ensure, for a call with at least one argument of typecomplex<T>:
- If either argument has type
complex<long double>or typelong double, then both arguments are effectively cast tocomplex<long double>.- Otherwise, if either argument has type
complex<double>,double, or an integer type, then both arguments are effectively cast tocomplex<double>.- Otherwise, if either argument has type
complex<float>orfloat, then both arguments are effectively cast tocomplex<float>.
libc++ will return the correct type. libstdc++ will not. https://godbolt.org/z/_TscRV
Also tracked by Microsoft-internal VSO-177118.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!