Bug 97920 - Strange behavior of simple integer sum() function
Summary: Strange behavior of simple integer sum() function
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.1.0.3 release
Hardware: All All
: high major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2016-02-17 04:03 UTC by Franklin Weng
Modified: 2016-03-30 16:05 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Wrong sum under LibreOffice 5.1.0.3 (28.21 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-02-17 04:03 UTC, Franklin Weng
Details
The screenshot opening the file (115.87 KB, image/png)
2016-02-17 04:04 UTC, Franklin Weng
Details
Correct in A9 cell if I set it to =sum(C9:H9) (116.59 KB, image/png)
2016-02-17 04:04 UTC, Franklin Weng
Details
Sum was wrong if I set A9 to sum(C9:I9) (116.45 KB, image/png)
2016-02-17 04:06 UTC, Franklin Weng
Details
Correct in A9 again if I set it to sum(C9:J9) (116.56 KB, image/png)
2016-02-17 04:07 UTC, Franklin Weng
Details
Incorrect sums in column J, correct percents in column K (19.16 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-02-18 16:54 UTC, Chris Mayfield
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Franklin Weng 2016-02-17 04:03:27 UTC
Created attachment 122706 [details]
Wrong sum under LibreOffice 5.1.0.3

Please see the attached ods file.

In the Column A, the sum were wrong since A9 (=sum(C9:I9)).
A2-A8 were correct.

If I changed the formula to sum(C9:H9) or sum(C9:J9) the sum were correct too.
Only wrong when I set it to sum(C9:I9).

The following attached images showed this.

Besides, only LibreOffice 5.1.0 has this problem.  I tried it with LibreOffice 5.1.0.3 Windows versions running under Windows 8.  All other version I tested so far were correct.

I haven't tested it with 5.1.0 Linux version, but 4.4.7 under Linux the sum were correct too.
Comment 1 Franklin Weng 2016-02-17 04:04:12 UTC
Created attachment 122707 [details]
The screenshot opening the file
Comment 2 Franklin Weng 2016-02-17 04:04:47 UTC
Created attachment 122708 [details]
Correct in A9 cell if I set it to =sum(C9:H9)
Comment 3 Franklin Weng 2016-02-17 04:06:49 UTC
Created attachment 122709 [details]
Sum was wrong if I set A9 to sum(C9:I9)
Comment 4 Franklin Weng 2016-02-17 04:07:35 UTC
Created attachment 122710 [details]
Correct in A9 again if I set it to sum(C9:J9)
Comment 5 Chris Mayfield 2016-02-18 16:54:50 UTC
Created attachment 122774 [details]
Incorrect sums in column J, correct percents in column K
Comment 6 Chris Mayfield 2016-02-18 16:55:16 UTC
I am seeing this issue too -- it appears to affect horizontal sums. See attached sum_and_pct.ods, created using 1:5.1.0~rc3-0ubuntu1~trusty0. What's interesting is that the sums are 0, but the percentages in the next column are correct. When I open this file on my Mac using version 4.3.7.2, it displays the correct sums.
Comment 7 Buovjaga 2016-02-20 14:45:05 UTC
A9 is 45 for me in attachment 122706 [details]

Sums in J are not 0 for me in attachment 122774 [details]

Win 7 Pro 64-bit, Version: 5.1.0.3 (x64)
Build ID: 5e3e00a007d9b3b6efb6797a8b8e57b51ab1f737
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
Locale: fi-FI (fi_FI)

Version: 5.2.0.0.alpha0+
Build ID: ef02de2698d90fd874bddf3146165cbe85487bc5
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-02-19_23:40:50
Locale: fi-FI (fi_FI)
Comment 8 raal 2016-02-20 15:16:31 UTC
Confirm.
 Version: 5.2.0.0.alpha0+
Build ID: ef02de2698d90fd874bddf3146165cbe85487bc5
CPU Threads: 1; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-02-19_23:40:50

even CTRL+shift+F9  doesn't help. When rewrite the formula by drag formula from A8, then it works. When I delete formula and write formula again, the result is bad.

Raise importance, because SUM is basic function. 

<meta:generator>LibreOffice/5.1.0.3$Windows_x86


works correct in Version: 4.3.0.0.alpha1+, regression.
Comment 9 raal 2016-02-22 11:52:53 UTC
This seems to have begun at the below commit.
Adding Cc: to Jan Holesovsky; Could you possibly take a look at this one? Thanks
 0e1c7b8968a73e15cd6b03dc5a99b31aa9c86f9a is the first bad commit
commit 0e1c7b8968a73e15cd6b03dc5a99b31aa9c86f9a
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Wed Dec 9 00:28:54 2015 -0800

    source 0bf39de7e54f041ade0f659db47cabcc6589ada7

    source 0bf39de7e54f041ade0f659db47cabcc6589ada7

:040000 040000 bd5626b7099668d9f2edbea7cf3fc86b44758421 e8a0694e88355f9a10321ca4e78ee2669e7d366c M      instdir

author	Jan Holesovsky <kendy@collabora.com>	2015-11-30 11:32:16 (GMT)
committer	Jan Holesovsky <kendy@collabora.com>	2015-12-03 15:14:03 (GMT)
commit 0bf39de7e54f041ade0f659db47cabcc6589ada7 (patch)
tree 8367f986fdb0d8c4ebdb036c13761de7aba4aff0
parent 361dfe0cced6e621eea7b6b5e087b1aec9c3ba4a (diff)
sc interperter: Turn it on for a subset of operations by default.
Comment 10 Markus Mohrhard 2016-03-22 23:06:18 UTC
Might be a duplicated of Bug 98657 which I just fixed by globally disabling the SW group interpreter.
Comment 11 Jan Holesovsky 2016-03-30 12:49:42 UTC
Franklin, Raal: Unfortunately I am having trouble reproducing it :-(

I tried in the recent master (and libreoffice-5-1), and the problem did not appear to me.  I tried to revert the fix from bug 98657; and still I cannot reproduce the behaviour.

Franklin, Raal: Can you please re-try with the recent libreoffice-5-1 nightly build?  Is the behaviour Windows-only?  (I tested on Linux.)

If you still see the problem, can you provide me with detailed step-by-step instructions?  Like

* click mouse in A9
* press Delete
* type =sum(C9:I9)
* now you can see the wrong result

Or something - that will help me to reproduce it.  Thank you!
Comment 12 Andrew Horsfield 2016-03-30 13:08:35 UTC
I have a similar problem with LO 5.1.0.3 on a Mac.

I have a rectangular grid of numbers, and want to find the total for each row. If I put =sum(c4:r4) in the top cell of the column holding the sums, and then copy the formula to all cells below (ctrl-C, highlight cells, ctrl-V) then I get zero for each row. However, if I highlight the first half of the column (about 50 rows), and paste into that, then highlight the second half and paste into that, it works.
Comment 13 Jan Holesovsky 2016-03-30 13:29:01 UTC
Andrew: Can you please try with this build:

http://dev-builds.libreoffice.org/daily/libreoffice-5-1/MacOSX-x86_64@49-TDF/2016-03-30_12.19.43/

5.1.0.3 is too old, I've pushed recently a fix that I'd need to know if it helped in this case, or not :-)

Thank you!
Comment 14 Andrew Horsfield 2016-03-30 13:44:03 UTC
When I paste the sum formula into all cells in the column, it now behaves as expected. So your fix passes this test. Thank you for fixing it.
Comment 15 Jan Holesovsky 2016-03-30 13:52:58 UTC
Andrew: Thank you for confirming!  Let's close this bug then :-)

Franklin, Raal: Please feel free to re-open if you still see the problem in your use case; in that case please provide more info.
Comment 16 raal 2016-03-30 16:05:43 UTC
(In reply to Jan Holesovsky from comment #15)
> Andrew: Thank you for confirming!  Let's close this bug then :-)
> 
> Franklin, Raal: Please feel free to re-open if you still see the problem in
> your use case; in that case please provide more info.

Works for me with Version: 5.2.0.0.alpha0+
Build ID: 5a8cd51780eaf362536284ee8bd388916a172690
CPU Threads: 1; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2016-03-24_06:51:09