[Libreoffice-bugs] [Bug 137670] New: Simplify uses of sal_math_Double
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Thu Oct 22 07:10:08 UTC 2020
https://bugs.documentfoundation.org/show_bug.cgi?id=137670
Bug ID: 137670
Summary: Simplify uses of sal_math_Double
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Keywords: difficultyBeginner, easyHack, skillCpp
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: libreoffice-bugs at lists.freedesktop.org
Reporter: mikekaganski at hotmail.com
CC: sbergman at redhat.com
We have a helper union sal_math_Double (defined in include/sal/mathconf.h) to
help low-level access to double parts. In several places, double values are
reinterpret_cast to it, to access parts of the IEEE 754 structure. E.g., in
sc/source/core/tool/interpr6.cxx:
> sal_uInt32 nErr = reinterpret_cast< sal_math_Double * >(&aRes.mfFirst)->nan_parts.fraction_lo;
mathconf.h could define a helper function to make it simpler, which could take
a reference to double, and return it cast to reference to sal_math_Double, so
the above code could be re-written to something like
> sal_uInt32 nErr = sal_math_DoubleParts(aRes.mfFirst).nan_parts.fraction_lo;
Besides shorter form, the actual benefit is decreased use of unsafe
reinterpret_cast, thus providing better type safety.
To use references in the C header, of course, the function must be enclosed in
the "#if defined __cplusplus" block; or be defined in another helper header.
Alternatively, it should take and return pointers (less ideal IMO).
So the task is to implement such a function, and replace existing cases of
reinterpret_casts of doubles to the struct with use of this function.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20201022/b315df50/attachment.htm>
More information about the Libreoffice-bugs
mailing list