February 06, 2004 [BUG](low) incorrect initializing of arrays not reported | ||||
---|---|---|---|---|
| ||||
dmd 0.79, WIN98SE void main(){ static int[] bar=[0,,,3]; printf("%d\n", bar[1]); } this compiles and outputs `3'. So long. |
February 06, 2004 Re: [BUG](low) incorrect initializing of arrays not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | Manfred Nowak wrote: >dmd 0.79, WIN98SE > >void main(){ > static int[] bar=[0,,,3]; > > printf("%d\n", bar[1]); >} > >this compiles and outputs `3'. > >So long. > > This is to do with empty comma operators being ignored. If you did void main() { static int[] bar=[0,,,3]; printf("%d\n", bar.length); } you would get 2. The parhaps the code should cause a compilation error (or initialize emptys with the default (ie constructor)). -- -Anderson: http://badmama.com.au/~anderson/ |
Copyright © 1999-2021 by the D Language Foundation