Bug 171093 - Formula compiler wrongly adds a zero to formula in case of erroneous formula
Summary: Formula compiler wrongly adds a zero to formula in case of erroneous formula
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-03-01 18:15 UTC by Fab Stz
Modified: 2026-05-25 13:05 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fab Stz 2026-03-01 18:15:26 UTC
Be sure to be in french of german locale (there is no issue with en-GB for example). For this, go to "options / languages & locales / general / locale setting" set locale to FrenchFrance or GermanGermany.

In a cell put: "=1+2,5", it renders "3,5".

Now do a search/replace. Search "+", replace by "PLUS" (search replace in formula).

It will become "=1plus20,5"

It should be "=1plus2,5"

This problem doesn't happen with en-GB locale, which by the uses uses "." as decimal separator, while fr-FR, de-DR uses "," as decimal separator.
Comment 1 Fab Stz 2026-03-01 18:16:25 UTC
confirmed on IRC #libreoffice 2026-03-01. It happens also on 26.2.1

[18:40] <bastif_> I have a very weird behavior in calc. Take formula "=1+2.5" (or a comma instead of a dot, since I'm on french locale).
[18:40] <bastif_> Then do a search/replace. Search "+" replace by "PLUS"
[18:40] <bastif_> The formula becomes "=1PLUS20.5"
[18:42] <bastif_> The additional 0 is very unexpected. Tested on LO 25.2.3 and 26.2.0
[18:42] <mikekaganski> bastif_: so - that looks exactly what you did? Unless you wanted to search not in formulas, which is possible in Find/Replace dialog?
[18:42] <mikekaganski> aha
[18:43] <bastif_> Did you notice the additonal zero ?
[18:43] <mikekaganski> bastif_: seems to work here using 26.2.1
[18:44] <mikekaganski> without 0
[18:44] <mikekaganski> but "plus" is lowercase in the result (because it's not a known function)
[18:44] <bastif_> Which locale do you have?
[18:44] <mikekaganski> =1plus2.5
[18:44] <mikekaganski> en-GB
[18:47] <bastif_> Ok, I tried with your locale and it's works like you. Can you try fr-FR locale and a comma instead of a dot "=1+2,5" ?
[18:51] <bastif_> no need to restart, it can be changed in options / languages & locales / general / locale setting.
[18:52] <bastif_> It is also wrong with german locale. "=1+2,5" becomes "=1plus20,5"
[19:05] <bastif_> mikekaganski: could you try ^ and confirm the issue is you swith the locale ?
[19:05] <bastif_> s/is you swith/if you switch/
[19:07] <mikekaganski> bastif_: yes, repro
[19:08] <bastif_> thanks!
Comment 2 Laurent Balland 2026-05-16 08:08:53 UTC
Reproduce with Version: 26.8.0.0.alpha0+ (X86_64)
Build ID: ee2fe6acdba158d48d1166562ce02752d35524d2
CPU threads: 8; OS: Linux 6.17; UI render: default; VCL: gtk3
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded

Conditions to reproduce:
- cell must be a formula (replacement in Values has no bug)
- element following the string to be replaced must be a decimal number
- replacement string must not contain whitespace
- the new formula must generate an error 509:"Operator missing". For instance, replacing ",36/2" by "3" in "=11,36/2,5" gives "=113,5" without added '0' (no bug), whereas replacing "36/2" by "3" in same formula gives "=11,30,5" (bug: a '0' was added)

- a '0' is inserted left of the decimal separator

I was able to reproduce the bug with a point as decimal separator:
replace "36/2" by "3" in "=11.36/2.5" should give ="11.3.5" but gives "=11.30.5" with an added '0'

'0' seems to be added in ScCompiler::CompileString
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/compiler.cxx?r=f3bd8077537646d4f2b9f4f3b98428c54673ec99#5017
Comment 3 Laurent Balland 2026-05-25 13:04:44 UTC
I think I understand what is happening behind this strange behavior:
After replacement, the formula "=1plus2,5" is sent to formula compiler to understand it. In some cases, compiler consider that an operator is missing between "1plus2" (an unknown name of variable) and the end of the string ",5", which is treated as a double and converted to "0,5".

So no need to make a replacement. Just type the erroneous formula with fr-FR locale
=1PLUS2,5
and the formula compiler will transform it in
=1plus20,5
for the same reason
Or with en-US, type formula
=11.3.5
and the formula compiler will transform it in
=11.30.5