[Issue 481] Letting compiler determine length for fixed-length arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 10 20:03:41 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=481
--- Comment #14 from bearophile_hugs at eml.cc 2012-08-10 20:03:23 PDT ---
A bug I've just found. Originally I was using 20 points, and I needed them in a
fixed-size array. Later I have removed some of them to reduce the testing time,
but I have forgotten to update the number of items in P[20].
The compiler gives me no compilation errors (it gives errors only if the number
is less than the number of given items), the missing array items are filled
with P(0,0) by the compiler, the duplicated zero points produce an almost
correct result, but not exactly correct, so I have to spend minutes to spot the
problem. This is the minimized code, that shows this simple bug the compiler
isn't able to find for me:
import std.typecons;
alias Tuple!(int, int) P;
enum P[20] a = [P(62, -67), P(4, -71), P(-86, 71), P(-25, -53), P(-23, 70),
P(46, -34), P(-92, -62), P(-15, 89), P(100, 42), P(-4, 43),
P(21, 59), P(86, -25), P(93, -52), P(-41, -48), P(-45, 76),
P(85, -43), P(-69, 64)];
void main() {}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list