Skip to content

<complex>: _LDtest looks quite questionable #5642

@frederick-vs-ja

Description

@frederick-vs-ja

#1316 added _LDtest to handle Intel 80-bit long double, which is normally unsupported by MSVC STL.

But the uses of _LDtest don't seem right according to MSVC STL's function definition:

STL/stl/src/xldtest.cpp

Lines 10 to 12 in 313964b

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

With strict aliasing violation ignored, _LDtest effectively takes the initial 64 bits of a long double, then treats the part as a double value, and then inspect such a value. This doesn't properly work when long double and double have different formats.

(Originally posted by @statementreply in #2073 (comment))

I wonder whether we really need to inspect the value representation here. If any case, can't we use usual comparison for 80-bit long double (x != x for NaN, x > max() || x < -max() for Inf)? @simmse

Moreover, it seems that _LDtest, _LSinh, and _LCosh are unnecessary (and can be removed in vNext) as we can dispatch to functions for double.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedresolvedSuccessfully resolved without a commit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions