digitalmars.D.learn - Static Array with negative index results in a strange error-message
- Dgame (6/6) Apr 23 2018 char[-1] c;
- Steven Schveighoffer (8/17) Apr 23 2018 Hm.. at least it's detected. I actually don't think the message is
- Dgame (6/26) Apr 23 2018 C's error message is
- Dgame (5/5) Apr 23 2018 It's really fun playing around:
- Steven Schveighoffer (4/15) Apr 23 2018 Yes, this is an ICE (Internal compiler error). Those should ALWAYS be
char[-1] c; results in Error: char[18446744073709551615LU] size 1 * 18446744073709551615 exceeds 0x7fffffff size limit for static array Should we fix that? A negative index should be IMO detected sooner/with a cleaner error message.
Apr 23 2018
On 4/23/18 9:32 AM, Dgame wrote:char[-1] c; results in Error: char[18446744073709551615LU] size 1 * 18446744073709551615 exceeds 0x7fffffff size limit for static array Should we fix that? A negative index should be IMO detected sooner/with a cleaner error message.Hm.. at least it's detected. I actually don't think the message is wrong: -1 is a valid size_t literal, and results in that number. if you did: enum size_t x = -1; char[x] c; You would get the same result, and I don't know how we would fix that. -Steve
Apr 23 2018
On Monday, 23 April 2018 at 13:48:07 UTC, Steven Schveighoffer wrote:On 4/23/18 9:32 AM, Dgame wrote:C's error message is error: 'c' declared as an array with a negative size char c[-1]; That is more understandable.char[-1] c; results in Error: char[18446744073709551615LU] size 1 * 18446744073709551615 exceeds 0x7fffffff size limit for static array Should we fix that? A negative index should be IMO detected sooner/with a cleaner error message.Hm.. at least it's detected. I actually don't think the message is wrong: -1 is a valid size_t literal, and results in that number. if you did: enum size_t x = -1; char[x] c; You would get the same result, and I don't know how we would fix that. -Steve
Apr 23 2018
It's really fun playing around: char[int.max - 1] c; results in Internal error: dmd/backend/cgcod.c 634 with DMD 2.079. Guess I or somebody else should report this.
Apr 23 2018
On 4/23/18 11:09 AM, Dgame wrote:It's really fun playing around: char[int.max - 1] c; results in Internal error: dmd/backend/cgcod.c 634 with DMD 2.079. Guess I or somebody else should report this.Yes, this is an ICE (Internal compiler error). Those should ALWAYS be reported. -Steve
Apr 23 2018