www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - bound checking & constant index

reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


XPASS:
#
# const int i = -1;
# int[2] array;
# array[i] = 1;
#

http://dstress.kuehne.cn/nocompile/bounds_checking_04.d

Thomas

-----BEGIN PGP SIGNATURE-----

iD8DBQFCZBt/3w+/yD4P9tIRAqfkAKC91ZvKkjYq76F+ML66vQXN7T0XYgCfXSVo
wmtNloKBDwA4//5aoz61BWI=
=WMRG
-----END PGP SIGNATURE-----
Apr 18 2005
next sibling parent reply Burton Radons <burton-radons smocky.com> writes:
Thomas Kuehne wrote:

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 
 XPASS:
 #
 # const int i = -1;
 # int[2] array;
 # array[i] = 1;
 #
 
 http://dstress.kuehne.cn/nocompile/bounds_checking_04.d

Update your DMD; 0.121 says: d.d(5): array index [-1] is outside array bounds [0 .. 2] I don't think this should be in a stress test either because detecting these scenarios is a quality-of-implementation issue. But it would be useful to implementors to have this information.
Apr 18 2005
next sibling parent reply Burton Radons <burton-radons smocky.com> writes:
I see you have 0.121 installed, Thomas.  Sorry, what do you mean by your 
post?  It's pretty terse.  :)
Apr 18 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Burton Radons schrieb am Mon, 18 Apr 2005 19:26:38 -0700:
 I see you have 0.121 installed, Thomas.  Sorry, what do you mean by your 
 post?  It's pretty terse.  :)

Sorry, must have been a typo ... -----BEGIN PGP SIGNATURE----- iD8DBQFCZHei3w+/yD4P9tIRApq/AKDFoNVRJrYFt2SBMPjGNl0j83dBCgCgocC5 av0dwvei0qZBHuPgktbLN8M= =dsf9 -----END PGP SIGNATURE-----
Apr 18 2005
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Burton Radons wrote:
 Thomas Kuehne wrote:
 
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1


 XPASS:
 #
 # const int i = -1;
 # int[2] array;
 # array[i] = 1;
 #

 http://dstress.kuehne.cn/nocompile/bounds_checking_04.d

Update your DMD; 0.121 says: d.d(5): array index [-1] is outside array bounds [0 .. 2] I don't think this should be in a stress test either because detecting these scenarios is a quality-of-implementation issue. But it would be useful to implementors to have this information.

In certain conditions, not having compile-time ABC would be totally naive. In this instance, the code is semantically identical to int[2] array; array[-1] = 1; and should compile/behave in the same way. Generally, if the array is static and the index is a compile-time constant, the only sane solution is to generate a direct access to the memory location. To generate all the run-time ABC code for such a trivial case would be almost a pessimisation, and the only other alternative would be to generate an equally perverse, explicit throw new ArrayBoundsError(...); statement at that point. It follows that it's pretty basic to have this as a compiler error. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 19 2005
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 XPASS:
 #
 # const int i = -1;
 # int[2] array;
 # array[i] = 1;
 #
 
 http://dstress.kuehne.cn/nocompile/bounds_checking_04.d

Just spotted another name you've used twice: bounds_checking_02. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 19 2005