Bug 167468 - XMATCH with mode=0 and searchdirection=-1 returns #N/A where 1 should be expected
Summary: XMATCH with mode=0 and searchdirection=-1 returns #N/A where 1 should be expe...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.2.4.3 release
Hardware: All All
: medium normal
Assignee: Balázs Varga
URL:
Whiteboard: target:26.2.0 target:25.8.0.2 target:...
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2025-07-11 16:03 UTC by Wolfgang Jäger
Modified: 2025-07-24 08:16 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
demonstrating the bug (14.61 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-07-11 16:03 UTC, Wolfgang Jäger
Details
corrected loop (1.09 KB, patch)
2025-07-12 00:47 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2025-07-11 16:03:38 UTC
Created attachment 201759 [details]
demonstrating the bug

Also present in 25.8.0.0.beta1
The summary says it all.
XMATCH with mode=0 and searchdirection=-1 returns #N/A where 1 should be expected
Comment 1 Werner Tietz 2025-07-11 17:02:07 UTC
Confirmed!

@Wolfgang:
another workaround:
=XMATCH("\d+";B2:E2;3;-1)
Comment 2 m_a_riosv 2025-07-11 22:02:36 UTC
Reproducible:
Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7ef1c437f30b0869a5b9fa33809bac2c6665ace3
CPU threads: 16; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Raster; VCL: win
Locale: en-US (es_ES); UI: en-US
Calc: CL threaded

The file, saved as xlsx after set up the use of wildcards, none of the formulas work with:
Microsoft® Excel® para Microsoft 365 MSO (versión 2506 compilación 16.0.18925.20076) de 64 bits
Comment 3 Regina Henschel 2025-07-12 00:47:07 UTC
Created attachment 201763 [details]
corrected loop

Off-by-one error. BTW, changing i>0 to i>=0 will not work because SCSIZE is unsigned integer.
Comment 4 Óvári 2025-07-13 08:48:03 UTC
Balázs can you please have a look? Thank you
Comment 5 Commit Notification 2025-07-18 07:07:37 UTC
Balazs Varga committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/649346506b8ec0670e35d30c5e04358e40244c36

tdf#167468 - sc: fix XMATCH with mode=0 and searchdirection=-1

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2025-07-24 08:15:09 UTC
Balazs Varga committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/3a6c72a553d89e1b0f80858fd603916d66182212

tdf#167468 - sc: fix XMATCH with mode=0 and searchdirection=-1

It will be available in 25.8.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2025-07-24 08:16:12 UTC
Balazs Varga committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/04287a89f49b4dd29c9fcb393a4fddc02e673a7b

tdf#167468 - sc: fix XMATCH with mode=0 and searchdirection=-1

It will be available in 25.2.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.