sc/inc/kahan.hxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 5928323090fa5cd95866b46b91e292aabaddff73
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Sep 1 15:20:28 2023 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Sep 6 17:34:53 2023 +0200

    Resolves: tdf#156985 Treat adding two KahanSum differently
    
    When summing mixed formula cells and numeric cells, cell type runs are
    summed using KahanSum that when switching cell types are added. Using
    add() to explicitly add the rhs m_fError compensation value separately
    may had lead to effectively cancelling out the relation of sum and
    error, living on with an unrelated error value. Instead, add a "final"
    rhs sum+compensation.
    
    Change-Id: I751d3e0eeef9cd80482895c24f05b1ab667c3020
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156253
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit caafee1a4805e40d29be5c90f3a021ed6ef5c4d2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156431
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 3cb3b713e1f3b8abe8d9bb46c89f58c7efdf8196)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156444
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Reviewed-by: Hossein <hoss...@libreoffice.org>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sc/inc/kahan.hxx b/sc/inc/kahan.hxx
index 6c84f6eeef2e..ac97ae4394fa 100644
--- a/sc/inc/kahan.hxx
+++ b/sc/inc/kahan.hxx
@@ -71,8 +71,15 @@ public:
       */
     inline void add(const KahanSum& fSum)
     {
+#ifdef _WIN32
+        // For some odd unknown reason WIN32 fails badly with the
+        // sum+compensation value. Continue keeping the old though slightly off
+        // (see tdf#156985) explicit addition of the compensation value.
         add(fSum.m_fSum);
         add(fSum.m_fError);
+#else
+        add(fSum.m_fSum + fSum.m_fError);
+#endif
         add(fSum.m_fMem);
     }
 
@@ -82,8 +89,12 @@ public:
       */
     inline void subtract(const KahanSum& fSum)
     {
+#ifdef _WIN32
         add(-fSum.m_fSum);
         add(-fSum.m_fError);
+#else
+        add(-(fSum.m_fSum + fSum.m_fError));
+#endif
         add(-fSum.m_fMem);
     }
 

Reply via email to