<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - nested for-next loops: outer increment is wrong after leaving inner loop with "exit for""
href="https://bugs.documentfoundation.org/show_bug.cgi?id=123003">123003</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>nested for-next loops: outer increment is wrong after leaving inner loop with "exit for"
</td>
</tr>
<tr>
<th>Product</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Version</th>
<td>5.1.6.2 release
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>UNCONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>BASIC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>libreoffice-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>uwe.schmiedecke@gmx.de
</td>
</tr></table>
<p>
<div>
<pre>Description:
Loop count error:
after the inner loop is left using "exit for" the stmt "next ii" below will
increment the inner loop counter "jj" instead of "ii"!
function endOfSheet
for ii = 100 TO 16000
if oSheet.getCellRangeByName("A" & ii).String = "" then
' 20 Zeilen rückwärts suchen:
for jj = 1 to 101
if oSheet.getCellRangeByName("A" & (ii-jj)).String <> "" then
if jj > 20 then
endOfSheet = ii-jj+1
exit function
end if
exit for ' ***** THIS CAUSES THE ERROR!!! (see above)
endif
next jj
end if
next ii ' ****** HERE THE ERROR CAN BE OBSERVED USING DEBUGGER
end function
my OS version is Ubuntu 16.04.5 LTS
Libreoffice-Version: 5.1.6.2
Build-ID: 1:5.1.6~rc2-0ubuntu1~xenial4
CPU-Threads: 4; BS-Version: Linux 4.4; UI-Render: Standard;
Steps to Reproduce:
1. test the above example using debugger
2.
3.
Actual Results:
the statement "next ii" increments jj instad of ii
Expected Results:
after the inner "exit for" the outer loop should increment ii and not jj
Reproducible: Always
User Profile Reset: No
Additional Info:</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>