Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strengthen exception specification for complex #3880

Merged
merged 8 commits into from
Jul 26, 2023
470 changes: 261 additions & 209 deletions stl/inc/complex

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -7113,15 +7113,15 @@ struct _CXX17_DEPRECATE_ITERATOR_BASE_CLASS iterator { // base type for iterator
};

template <class _Ty, enable_if_t<is_floating_point_v<_Ty>, int> = 0>
_NODISCARD constexpr auto _Float_abs_bits(const _Ty& _Xx) {
_NODISCARD constexpr auto _Float_abs_bits(const _Ty& _Xx) noexcept {
using _Traits = _Floating_type_traits<_Ty>;
using _Uint_type = typename _Traits::_Uint_type;
const auto _Bits = _Bit_cast<_Uint_type>(_Xx);
return _Bits & ~_Traits::_Shifted_sign_mask;
}

template <class _Ty, enable_if_t<is_floating_point_v<_Ty>, int> = 0>
_NODISCARD constexpr _Ty _Float_abs(const _Ty _Xx) { // constexpr floating-point abs()
_NODISCARD constexpr _Ty _Float_abs(const _Ty _Xx) noexcept { // constexpr floating-point abs()
return _Bit_cast<_Ty>(_Float_abs_bits(_Xx));
}

Expand All @@ -7134,7 +7134,7 @@ _NODISCARD constexpr _Ty _Float_copysign(const _Ty _Magnitude, const _Ty _Sign)
}

template <class _Ty, enable_if_t<is_floating_point_v<_Ty>, int> = 0>
_NODISCARD constexpr bool _Is_nan(const _Ty _Xx) { // constexpr isnan()
_NODISCARD constexpr bool _Is_nan(const _Ty _Xx) noexcept { // constexpr isnan()
using _Traits = _Floating_type_traits<_Ty>;
return _Float_abs_bits(_Xx) > _Traits::_Shifted_exponent_mask;
}
Expand All @@ -7144,20 +7144,20 @@ _NODISCARD constexpr bool _Is_nan(const _Ty _Xx) { // constexpr isnan()
// When the value is a 32-bit or 64-bit signaling NaN, the conversion to/from 80-bit raises FE_INVALID
// and turns it into a quiet NaN. This behavior is undesirable if we want to test for signaling NaNs.
template <class _Ty, enable_if_t<is_floating_point_v<_Ty>, int> = 0>
_NODISCARD constexpr bool _Is_signaling_nan(const _Ty& _Xx) { // returns true if input is a signaling NaN
_NODISCARD constexpr bool _Is_signaling_nan(const _Ty& _Xx) noexcept { // returns true if input is a signaling NaN
using _Traits = _Floating_type_traits<_Ty>;
const auto _Abs_bits = _Float_abs_bits(_Xx);
return _Abs_bits > _Traits::_Shifted_exponent_mask && ((_Abs_bits & _Traits::_Special_nan_mantissa_mask) == 0);
}

template <class _Ty, enable_if_t<is_floating_point_v<_Ty>, int> = 0>
_NODISCARD constexpr bool _Is_inf(const _Ty _Xx) { // constexpr isinf()
_NODISCARD constexpr bool _Is_inf(const _Ty _Xx) noexcept { // constexpr isinf()
using _Traits = _Floating_type_traits<_Ty>;
return _Float_abs_bits(_Xx) == _Traits::_Shifted_exponent_mask;
}

template <class _Ty, enable_if_t<is_floating_point_v<_Ty>, int> = 0>
_NODISCARD constexpr bool _Is_finite(const _Ty _Xx) { // constexpr isfinite()
_NODISCARD constexpr bool _Is_finite(const _Ty _Xx) noexcept { // constexpr isfinite()
using _Traits = _Floating_type_traits<_Ty>;
return _Float_abs_bits(_Xx) < _Traits::_Shifted_exponent_mask;
}
Expand Down
24 changes: 12 additions & 12 deletions stl/inc/ymath.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ _EXTERN_C_UNLESS_PURE
#define _INFCODE 1
#define _NANCODE 2

_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double, double);
_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Sinh(double, double);
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Exp(double*, double, short);

_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float, float);
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FSinh(float, float);
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FExp(float*, float, short);

_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LCosh(long double, long double);
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double*);
_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LSinh(long double, long double);
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LExp(long double*, long double, short);
_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double, double) noexcept;
_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Sinh(double, double) noexcept;
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Exp(double*, double, short) noexcept;

_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float, float) noexcept;
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FSinh(float, float) noexcept;
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FExp(float*, float, short) noexcept;

_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LCosh(long double, long double) noexcept;
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double*) noexcept;
_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LSinh(long double, long double) noexcept;
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LExp(long double*, long double, short) noexcept;

_END_EXTERN_C_UNLESS_PURE

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xcosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double x, double y) { // compute y * cosh(x), |y| <= 1
_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double x, double y) noexcept { // compute y * cosh(x), |y| <= 1
switch (_Dtest(&x)) { // test for special codes
case _NANCODE:
case _INFCODE:
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xdint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _Dint(double* px, short xexp) { // test and drop (scaled) fraction bits
short _Dint(double* px, short xexp) noexcept { // test and drop (scaled) fraction bits
const auto ps = reinterpret_cast<_Dval*>(px);
short xchar = (ps->_Sh[_D0] & _DMASK) >> _DOFF;

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xdnorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _Dnorm(_Dval* ps) { // normalize double fraction
short _Dnorm(_Dval* ps) noexcept { // normalize double fraction
short xchar = 1;
unsigned short sign = static_cast<unsigned short>(ps->_Sh[_D0] & _DSIGN);

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xdscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _Dscale(double* px, long lexp) { // scale *px by 2^xexp with checking
short _Dscale(double* px, long lexp) noexcept { // scale *px by 2^xexp with checking
const auto ps = reinterpret_cast<_Dval*>(px);
short xchar = static_cast<short>((ps->_Sh[_D0] & _DMASK) >> _DOFF);

Expand Down
4 changes: 2 additions & 2 deletions stl/src/xdtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) { // categorize *px
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept { // categorize *px
const auto ps = reinterpret_cast<_Dval*>(px);

if ((ps->_Sh[_D0] & _DMASK) == _DMAX << _DOFF) {
Expand All @@ -20,7 +20,7 @@ _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) { // categorize *
}
}

unsigned short* _Pmsw(double* px) { // get pointer to msw
unsigned short* _Pmsw(double* px) noexcept { // get pointer to msw
return &reinterpret_cast<_Dval*>(px)->_Sh[_D0];
}

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xdunscal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _Dunscale(short* pex, double* px) { // separate *px to 1/2 <= |frac| < 1 and 2^*pex
short _Dunscale(short* pex, double* px) noexcept { // separate *px to 1/2 <= |frac| < 1 and 2^*pex
const auto ps = reinterpret_cast<_Dval*>(px);
short xchar = (ps->_Sh[_D0] & _DMASK) >> _DOFF;

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static const double hugexp = HUGE_EXP;
static const double invln2 = 1.4426950408889634073599246810018921;

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Exp(
double* px, double y, short eoff) { // compute y * e^(*px), (*px) finite, |y| not huge
double* px, double y, short eoff) noexcept { // compute y * e^(*px), (*px) finite, |y| not huge
if (y == 0.0) { // zero
*px = y;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfcosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float x, float y) { // compute y * cosh(x), |y| <= 1
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float x, float y) noexcept { // compute y * cosh(x), |y| <= 1
switch (_FDtest(&x)) { // test for special codes
case _NANCODE:
case _INFCODE:
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfdint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _FDint(float* px, short xexp) { // test and drop (scaled) fraction bits
short _FDint(float* px, short xexp) noexcept { // test and drop (scaled) fraction bits
const auto ps = reinterpret_cast<_Fval*>(px);
short xchar = (ps->_Sh[_F0] & _FMASK) >> _FOFF;

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfdnorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _FDnorm(_Fval* ps) { // normalize float fraction
short _FDnorm(_Fval* ps) noexcept { // normalize float fraction
short xchar = 1;
unsigned short sign = static_cast<unsigned short>(ps->_Sh[_F0] & _FSIGN);

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfdscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _FDscale(float* px, long lexp) { // scale *px by 2^xexp with checking
short _FDscale(float* px, long lexp) noexcept { // scale *px by 2^xexp with checking
const auto ps = reinterpret_cast<_Fval*>(px);
short xchar = static_cast<short>((ps->_Sh[_F0] & _FMASK) >> _FOFF);

Expand Down
4 changes: 2 additions & 2 deletions stl/src/xfdtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float* px) { // categorize *px
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float* px) noexcept { // categorize *px
const auto ps = reinterpret_cast<_Fval*>(px);

if ((ps->_Sh[_F0] & _FMASK) == _FMAX << _FOFF) {
Expand All @@ -19,7 +19,7 @@ _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float* px) { // categorize *
}
}

unsigned short* _FPmsw(float* px) { // get pointer to msw
unsigned short* _FPmsw(float* px) noexcept { // get pointer to msw
return &reinterpret_cast<_Fval*>(px)->_Sh[_F0];
}

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfdunsca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _FDunscale(short* pex, float* px) { // separate *px to 1/2 <= |frac| < 1 and 2^*pex
short _FDunscale(short* pex, float* px) noexcept { // separate *px to 1/2 <= |frac| < 1 and 2^*pex
const auto ps = reinterpret_cast<_Fval*>(px);
short xchar = (ps->_Sh[_F0] & _FMASK) >> _FOFF;

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xferaise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

void __CLRCALL_PURE_OR_CDECL _Feraise(int except) { // report floating-point exception
void __CLRCALL_PURE_OR_CDECL _Feraise(int except) noexcept { // report floating-point exception
if ((except & (_FE_DIVBYZERO | _FE_INVALID)) != 0) {
errno = EDOM;
} else if ((except & (_FE_UNDERFLOW | _FE_OVERFLOW)) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static const float hugexp = FHUGE_EXP;
static const float invln2 = 1.4426950408889634073599246810018921F;

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FExp(
float* px, float y, short eoff) { // compute y * e^(*px), (*px) finite, |y| not huge
float* px, float y, short eoff) noexcept { // compute y * e^(*px), (*px) finite, |y| not huge
if (y == 0.0F) { // zero
*px = y;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xfsinh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _EXTERN_C_UNLESS_PURE
// coefficients
static const float p[] = {0.00020400F, 0.00832983F, 0.16666737F, 0.99999998F};

_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FSinh(float x, float y) { // compute y * sinh(x), |y| <= 1
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FSinh(float x, float y) noexcept { // compute y * sinh(x), |y| <= 1
short neg;

switch (_FDtest(&x)) { // test for special codes
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xlcosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LCosh(
long double x, long double y) { // compute y * cosh(x), |y| <= 1
long double x, long double y) noexcept { // compute y * cosh(x), |y| <= 1
switch (_LDtest(&x)) { // test for special codes
case _NANCODE:
case _INFCODE:
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xldint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _LDint(long double* px, short xexp) { // test and drop (scaled) fraction bits -- 64-bit
short _LDint(long double* px, short xexp) noexcept { // test and drop (scaled) fraction bits -- 64-bit
return _Dint(reinterpret_cast<double*>(px), xexp);
}

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xldscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _LDscale(long double* px, long lexp) { // scale *px by 2^lexp with checking -- 64-bit
short _LDscale(long double* px, long lexp) noexcept { // scale *px by 2^lexp with checking -- 64-bit
return _Dscale(reinterpret_cast<double*>(px), lexp);
}

Expand Down
4 changes: 2 additions & 2 deletions stl/src/xldtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) { // categorize *px -- 64-bit
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept { // categorize *px -- 64-bit
return _Dtest(reinterpret_cast<double*>(px));
}

unsigned short* _LPmsw(long double* px) { // get pointer to msw
unsigned short* _LPmsw(long double* px) noexcept { // get pointer to msw
return &reinterpret_cast<_Lval*>(px)->_Sh[_L0];
}

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xldunsca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

short _LDunscale(short* pex, long double* px) { // separate *px to 1/2 <= |frac| < 1 and 2^*pex -- 64-bit
short _LDunscale(short* pex, long double* px) noexcept { // separate *px to 1/2 <= |frac| < 1 and 2^*pex -- 64-bit
return _Dunscale(pex, reinterpret_cast<double*>(px));
}

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xlexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static const long double hugexp = LHUGE_EXP;
static const long double invln2 = 1.4426950408889634073599246810018921L;

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LExp(
long double* px, long double y, short eoff) { // compute y * e^(*px), (*px) finite, |y| not huge
long double* px, long double y, short eoff) noexcept { // compute y * e^(*px), (*px) finite, |y| not huge
if (y == 0.0L) { // zero
*px = y;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xlpoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

_EXTERN_C_UNLESS_PURE

long double _LPoly(long double x, const long double* tab, int n) { // compute polynomial
long double _LPoly(long double x, const long double* tab, int n) noexcept { // compute polynomial
long double y;

for (y = *tab; 0 <= --n;) {
Expand Down
2 changes: 1 addition & 1 deletion stl/src/xlsinh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static constexpr long double p[] = {0.0000000000000028486835L, 0.000000000000764

static constexpr size_t NP = std::size(p) - 1;

_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LSinh(long double x, long double y) {
_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LSinh(long double x, long double y) noexcept {
// compute y * sinh(x), |y| <= 1
short neg;

Expand Down
Loading