[Libreoffice-bugs] [Bug 134712] New: Redim Preserve for existing arrays is accepted without any index range, but acts differently as if the unchange index ranges are made explicit.

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Fri Jul 10 10:45:17 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=134712

            Bug ID: 134712
           Summary: Redim Preserve for existing arrays is accepted without
                    any index range, but acts differently as if the
                    unchange index ranges are made explicit.
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: jag at psilosoph.de

To get the clue to the subject, go stepwise through the following code and
inspect the used array variables after each step:  

Sub directRedim()
REM Should closely be related to tdf#129256 .
Dim a(1 To 5, 1 To 3)
a(2, 2) = "§§"
b = a
Redim Preserve b
REM Should either be rejected (bad) or treated as if
REM the correct index ranges were explicitly given (good). See below!
a(2, 2) = "%%"
b(2, 2) = "Paragraphs"
a(2, 2) = "§§"
REM You see: You dont get it like with a dim c().
REM Basic applies the already set index ranges. 
The functional identity of b with a persists. 

Redim a(1 To 5, 1 To 3)
a(2, 2) = "§§"
b = a
Redim Preserve b(1 To 5, 1 To 3)
a(2, 2) = "%%"
b(2, 2) = "Paragraphs"
REM You see: b Now has an own identity disconnected from a
REM as if an assignment was following the the ByVal semantics. 

REM Actually the treatment in both variants is different in an error-prone way.
End Sub

For conceptual reasons the second variant is the only useful one.  
I'm not sure If there is much code relying on the first variant as is. 
Assuming it's rarely used because factually doing nothing, a unification of the
behavior in the sense that the first variant would work like the second one
should be safe enough. It would clearly simplify and make more efficient the
creation of copies of arrays. Such an operation soetimes is actually needed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200710/a4a5df32/attachment.htm>


More information about the Libreoffice-bugs mailing list