Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
April 18, 2005 bound checking & constant index | ||||
---|---|---|---|---|
| ||||
-----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----- |
April 19, 2005 Re: bound checking & constant index | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne | 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.
|
April 19, 2005 Re: bound checking & constant index | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | I see you have 0.121 installed, Thomas. Sorry, what do you mean by your post? It's pretty terse. :) |
April 19, 2005 Re: bound checking & constant index | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | -----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----- |
April 19, 2005 Re: bound checking & constant index | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | 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. |
April 19, 2005 Re: bound checking & constant index | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne | 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. |
Copyright © 1999-2021 by the D Language Foundation