Yes, it's still in Lucid. This is a subtle, nasty bug which needs to be fixed, or else a run-time exception raised to prevent silent data loss.
Basically, this problem makes the Array(...) constructor useless, i.e., too dangerous to use, unless you know and control all calling contexts to prevent mixing of String and Variant arrays. ** Description changed: Binary package hint: openoffice.org - In oo Basic, if an array is declared to have String elements, and is subsequently assigned to an array of Variant, - then ReDim Preserve fails to preserve elements which should be preserved. + In oo Basic, if an array is declared to have String elements, and is + subsequently is the LHS of an assignement from an array of Variant, then + a subsequent "ReDim Preserve" of the LHS array destroys the entire + contents of the array, i.e., the 'Preserve' does not work. - EXAMPLE: The following code displays a(0)='w' before the ReDim - Preserve, but a(0)='' afterwards + Please see the attached demo file. Here is the Basic code from that + file: - sub test - dim a() as String - - 'a = Array("w", "x", "y", "z") - dim b(0 to 3) as Variant - b(0) = "w" - b(1) = "x" - b(2) = "y" - b(3) = "z" - a = b - - MsgBox("BEFORE ReDim, LB=" & LBound(a) & " UB=" & UBound(a) & " a(0)='" & a(0) & "'") - ReDim Preserve a(LBound(a) to UBound(a)) - MsgBox("AFTER ReDim, LB=" & LBound(a) & " UB=" & UBound(a) & " a(0)='" & a(0) & "'") - end sub + dim thecopy() as String + + 'Oringal code in the app was: thecopy = Array("w", "x", "y", "z") + dim TEMP(0 to 3) as Variant + TEMP(0) = "www" + TEMP(1) = "xxx" + TEMP(2) = "yyy" + TEMP(3) = "zzz" + thecopy = TEMP + + MsgBox("BEFORE supposedly-no-op ReDim, thecopy[0]=" & thecopy(0)) + ReDim Preserve thecopy(LBound(thecopy) to UBound(thecopy)) + MsgBox("AFTER, thecopy[0]=" & thecopy(0)) + + (shows that thecopy[0] has been set to empty despite the 'Preserve') ProblemType: Bug Architecture: amd64 Date: Wed Nov 4 13:45:44 2009 DistroRelease: Ubuntu 9.10 ExecutablePath: /usr/lib/openoffice/program/soffice.bin Package: openoffice.org-core 1:3.1.1-5ubuntu1 [modified: var/lib/openoffice/basis3.1/program/services.rdb] ProcEnviron: - PATH=(custom, user) - LANG=en_US.UTF-8 - SHELL=/bin/bash + PATH=(custom, user) + LANG=en_US.UTF-8 + SHELL=/bin/bash ProcVersionSignature: Ubuntu 2.6.31-14.48-generic SourcePackage: openoffice.org Uname: Linux 2.6.31-14-generic x86_64 ** Tags added: apport-collected ** Description changed: Binary package hint: openoffice.org In oo Basic, if an array is declared to have String elements, and is subsequently is the LHS of an assignement from an array of Variant, then a subsequent "ReDim Preserve" of the LHS array destroys the entire contents of the array, i.e., the 'Preserve' does not work. Please see the attached demo file. Here is the Basic code from that file: dim thecopy() as String 'Oringal code in the app was: thecopy = Array("w", "x", "y", "z") dim TEMP(0 to 3) as Variant TEMP(0) = "www" TEMP(1) = "xxx" TEMP(2) = "yyy" TEMP(3) = "zzz" thecopy = TEMP MsgBox("BEFORE supposedly-no-op ReDim, thecopy[0]=" & thecopy(0)) ReDim Preserve thecopy(LBound(thecopy) to UBound(thecopy)) MsgBox("AFTER, thecopy[0]=" & thecopy(0)) (shows that thecopy[0] has been set to empty despite the 'Preserve') ProblemType: Bug Architecture: amd64 Date: Wed Nov 4 13:45:44 2009 DistroRelease: Ubuntu 9.10 ExecutablePath: /usr/lib/openoffice/program/soffice.bin Package: openoffice.org-core 1:3.1.1-5ubuntu1 [modified: var/lib/openoffice/basis3.1/program/services.rdb] ProcEnviron: PATH=(custom, user) LANG=en_US.UTF-8 SHELL=/bin/bash ProcVersionSignature: Ubuntu 2.6.31-14.48-generic SourcePackage: openoffice.org Uname: Linux 2.6.31-14-generic x86_64 + + + --- + Architecture: amd64 + DistroRelease: Ubuntu 10.04 + InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100429) + Package: openoffice.org-calc 1:3.2.0-7ubuntu4 + PackageArchitecture: amd64 + ProcEnviron: + PATH=(custom, user) + LANG=en_US.UTF-8 + SHELL=/bin/bash + ProcVersionSignature: Ubuntu 2.6.32-22.33-generic 2.6.32.11+drm33.2 + Tags: lucid + Uname: Linux 2.6.32-22-generic x86_64 + UserGroups: adm admin audio cdrom dialout dip fax floppy fuse games lpadmin netdev plugdev sambashare tape users vboxusers video -- Assigning Variant to String array causes ReDim Preserve to not work https://bugs.launchpad.net/bugs/474777 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs