(This bug report is mostly pro forma, in developer-speak, for people familiar with the code.) When using the software interpreter for formula groups (and not OpenCL), empty cells are mishandled by the SUM function as implemented by ArraySumFunctor. Empty cells are represented in the mpNumericArray as NaN values (without any payload, i.e. not error codes). These NaN then take part in the summation (either using SSE2 or plain C++ code), and the NaN propagates to the sum, as it should. Until then in ScInterpreter::TreatDoubleError() and the GetDoubleErrorValue() it calls the NaN gets translated into errNoValue, and displayed as #VALUE! This bug is not directly related to other serious issues in the software interpreter, see bug #97369.
One way to fix this would be to go through the values to be summed in the ArraySumFunctor actor, check if each is a NaN, and change it to a 0. But I wonder if that extra code will then compensate any performance gain from using this code in the first place. Another possibility would be to make sure that if we know that it is the software interpreter and not OpenCL that will be used, then not store NaNs in the array, but zeros.
s/actor/ctor
If I only could find the place in the code where the NaNs are stored in the array. It isn't ToDoubleArray::operator() in scmatrix.cxx, as I would have assumed. Sigh.
Sigh, and turning the NaNs into zeros in the ArraySumFunctor constructor isn't easy either because of constness: the mpNumericArray member of VectorRefArray is a pointer to const doubles. This is getting ridiculous.
OK, the NaNs come from the code in column2.cxx that calls rtl::math::setNan() to get a NaN and then stores that in some array.
https://gerrit.libreoffice.org/#/c/22152/
Tor Lillqvist committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=4d67506dee347c3a3a290e1f52af91048c4318bc tdf#97587: Treat plain NaNs as zero in the software interpreter for SUM It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Tor Lillqvist committed a patch related to this issue. It has been pushed to "libreoffice-5-1": http://cgit.freedesktop.org/libreoffice/core/commit/?id=aa064e8209e57ac91f16305d38e657d12a42093f&h=libreoffice-5-1 tdf#97587: Treat plain NaNs as zero in the software interpreter for SUM It will be available in 5.1.1. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
@Tor: shouldn't this one be marked as fixed, similar as bug 97369?
Marco Cecchetti committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=65694793e9588106e570d82b359c9c9e25a5cf0d sc - unit tests for tdf#97369 and tdf#97587 It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Also, http://cgit.freedesktop.org/libreoffice/core/commit/?id=cb01ea920550769e8a04b3cb809c70ed324ba342 tdf#97369/#97587 - Further fix SUMming in the software interpreter
Right - lets mark this fixed =)
(In reply to Commit Notification from comment #7) > Tor Lillqvist committed a patch related to this issue. > It has been pushed to "master": > > http://cgit.freedesktop.org/libreoffice/core/commit/ > ?id=4d67506dee347c3a3a290e1f52af91048c4318bc > > tdf#97587: Treat plain NaNs as zero in the software interpreter for SUM That code in both places uses !rtl::math::isFinite rather than rtl::math::isNan, so will also apply to infinite values (though the comments in the code only talk about NaN, in line what this bug report talks about).