Bug 124008 - array declared with own type can't redim
Summary: array declared with own type can't redim
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.2.0
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2019-03-11 21:12 UTC by F. Tremmel
Modified: 2021-01-25 06:59 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
example for redim with and without Perserve-flag and own types (14.37 KB, application/vnd.oasis.opendocument.text)
2019-03-11 21:12 UTC, F. Tremmel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description F. Tremmel 2019-03-11 21:12:00 UTC
Created attachment 149895 [details]
example for redim with and without Perserve-flag and own types

It‘s not longer possible to ReDim arrays declared with own types
but with the flag „preserve“ it still works.

Example:

Type myType
  sType    As String
  aValue   As Variant
  iNo      As Integer
  iRange   As Integer
  oColour  As Object
End Type

Sub Test
  Dim aType(10) As myType
  
  ReDim aType(20) As myType
  
  print Str(uBound(aType))    'result: 10
  
  ReDim Preserve aType(20) As myType
  
  print Str(uBound(aType))    'result: 20
  
End Sub
Comment 1 Xisco Faulí 2019-04-16 08:54:08 UTC
What result do you get ?

I get 10 and 20 in

Version: 6.3.0.0.alpha0+
Build ID: 033e1130a65ec7f0fa9c46e5124adc9d8bf724ba
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded

and

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 2 F. Tremmel 2019-04-16 11:10:09 UTC
With "ReDim" arrays are reduced or enlarged. The flag "Preserve" only ensures that old contents are preserved.
Without flag "Preserve" previous content will be deleted.

However, resizing arrays with their own data types works only with the "Preserve" flag. Without the "Preserve" flag, redimensioning is ignored.
This does not correspond to the description of the "ReDim" command and can lead to unwelcome behavior in the further course of the program.

It is expected that the resizing of arrays will work with their own data types. Whether the flag "Preserved" is set or not.
Comment 3 Xisco Faulí 2019-04-17 14:45:37 UTC
When you said "It‘s not longer possible to ReDim arrays declared with own types" does it mean it worked in the past? which version?
Comment 4 F. Tremmel 2019-04-18 09:14:56 UTC
I think it was 5.4.3 ReDim was working with own types.
Comment 5 QA Administrators 2019-05-08 21:47:51 UTC Comment hidden (obsolete)
Comment 6 himajin100000 2019-08-30 19:52:46 UTC
Reproducible with

バージョン: 6.4.0.0.alpha0+ (x64)
Build ID: 0fb2927a8fe06e6c3255544b8e4c4c9c0f5a67d3
CPU threads: 4; OS:Windows 10.0; UI render: default; VCL: win; 
TinderBox: Win-x86_64@62-TDF, Branch:master, Time: 2019-08-27_22:13:47
ロケール: ja-JP (ja_JP); UI-Language: ja-JP
Calc: CL

However, just a bit weirdly, on my private build with experimental patch on https://gerrit.libreoffice.org/#/c/67585/, which failed to pass at least one unittest/smoketest , the code given by the reporter resulted in two 20s.

(Honestly speaking, I lazily tried building on gerrit rather than on my local machine, and left several tens of crappy modifications for typos. This is embarrassing.)
Comment 7 Xisco Faulí 2019-09-25 16:10:32 UTC
(In reply to himajin100000 from comment #6)
> Reproducible with
> 
> バージョン: 6.4.0.0.alpha0+ (x64)
> Build ID: 0fb2927a8fe06e6c3255544b8e4c4c9c0f5a67d3
> CPU threads: 4; OS:Windows 10.0; UI render: default; VCL: win; 
> TinderBox: Win-x86_64@62-TDF, Branch:master, Time: 2019-08-27_22:13:47
> ロケール: ja-JP (ja_JP); UI-Language: ja-JP
> Calc: CL
> 
> However, just a bit weirdly, on my private build with experimental patch on
> https://gerrit.libreoffice.org/#/c/67585/, which failed to pass at least one
> unittest/smoketest , the code given by the reporter resulted in two 20s.
> 
> (Honestly speaking, I lazily tried building on gerrit rather than on my
> local machine, and left several tens of crappy modifications for typos. This
> is embarrassing.)

Moving to NEW then...
Comment 8 Oliver Brinzing 2019-11-30 13:06:49 UTC
(In reply to F. Tremmel from comment #0)
> It‘s not longer possible to ReDim arrays declared with own types
> but with the flag „preserve“ it still works.

with AOO 4.1.5 i get 10 and 20 too
-> setting: Inherited From OOo
Comment 9 Commit Notification 2021-01-25 06:58:37 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0426748927919dbfd4cf5c0bb904e21a90d6c9d7

tdf#136755, tdf#124008 - delete the variable beforehand REDIM

It will be available in 7.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.