Issue 18989 - The LBound and UBound functions fail with empty arrays from DimArray and Array()
Summary: The LBound and UBound functions fail with empty arrays from DimArray and Array()
Status: CLOSED FIXED
Alias: None
Product: udk
Classification: Code
Component: code (show other issues)
Version: OOo 1.1 RC3
Hardware: PC Linux, all
: P4 Trivial (vote)
Target Milestone: OOo 2.0
Assignee: chne
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-03 01:33 UTC by andrew
Modified: 2004-06-10 09:42 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description andrew 2003-09-03 01:33:23 UTC
the array a() is considered empty if LBound(a()) > UBound(a()).
For example.

Dim a() 
LBound(a()) = 0
UBound(a()) = -1

this is an empty array.

a() = DimArray()
a() = Array()

both return an empty array that can not be used with LBound or UBound.
Comment 1 ooo 2003-09-03 08:43:56 UTC
StarBASIC runtime, not API
Comment 2 ab 2003-09-03 10:09:58 UTC
I do not completely agree: Dim a() is a special contruct only created
to allow defining arrays that represent a sequence of size 0. So the
array created by Dim a() do contain one dimension of size 0 while the
arrays created by DimArray() and Array() do not even contain a dimen-
sion and it's not guaranteed anywhere that they should do. But ok, of
course it would be more consistant if they did. So I will have a look
and check if this can be changed without risking to break existing
Basic code.
Comment 3 andrew 2003-09-04 03:09:40 UTC
Had not thought of that! It is certainly true that ReDim works 
regardless. So Array() and DimArray return an array with no 
dimensions at all! Tricky!
Comment 4 ab 2004-04-28 14:23:49 UTC
As this was very easy to change and I saw no risk of breaking existing code,
I fixed the behaviour according to your suggestion. In any case it's more con-
sistant now.
Comment 5 ab 2004-05-24 13:23:02 UTC
To test:

sub main
	a = DimArray()
	print lbound( a() ), ubound( a() )
	
	a = Array()
	print lbound( a() ), ubound( a() )
end sub

Should each display 0, -1 now.
Comment 6 andrew 2004-05-24 13:41:16 UTC
Thanks AB,

I appreciate this one! :-)

Andrew Pitonyak
Comment 7 ab 2004-05-25 08:27:01 UTC
.
Comment 8 ab 2004-05-25 08:27:27 UTC
.
Comment 9 chne 2004-05-27 13:21:01 UTC
.
Comment 10 chne 2004-05-27 13:22:06 UTC
. 
Comment 11 chne 2004-05-27 13:22:33 UTC
VERIFIED in ab08fixes
Comment 12 chne 2004-06-10 09:42:21 UTC
ok in src660_m41-5