Hm, my compiler version is "Version 0.90.1 (07-17-2013) for win32".
OK, I have to revise my initial statement:
Code: Select all
Dim x() As Integer
Print LBound(x), UBound(x)
Sleep
This program indeed prints 0, -1
But:
Code: Select all
Dim y As Integer = -1
Dim x(y) As Integer
Print LBound(x), UBound(x)
Sleep
This program prints 0, 0!
You are right, a zero-size array is indeed a null pointer so @x(0) = 0 can be used to check, thanks.
However, I think that the second case I demonstrated should a) report 0, -1 as well and b) be allowed (even with -e). The reason is: The possibility to have empty arrays only as initial state is an obstacle. You cannot, for example, just copy an array by creating a new one with the same size and then copying data in a For loop. In fact, I would have several uses for empty arrays in my program, and the reason I tripped over this in the first place is that there is the case that something has 0 items and therefore a certain function will create an empty array (because the size is dynamically specified). This would mean that we would need to do an unnecessary step, such as this:
Code: Select all
Dim array() As Integer
If size > 0 Then ReDim array(size - 1) As Integer
...to circumvent this obstacle.