Bug in the spec or implementation?

simendsjo simen.endsjo at pandavre.com
Thu Aug 5 13:30:08 PDT 2010


On 05.08.2010 22:24, Steven Schveighoffer wrote:
> On Thu, 05 Aug 2010 16:00:35 -0400, simendsjo
> <simen.endsjo at pandavre.com> wrote:
>
>> On 05.08.2010 21:41, Steven Schveighoffer wrote:
(...)
>> Seems there are plenty of errors in the spec though...
>> It will be very difficult to learn the language if the spec and
>> implementation is different. Spec or compiler bug?
>>
>>
>> char[] a = new char[20];
>> char[] b = a[0..10];
>> assert(a.ptr == b.ptr); // hmm.. does slice has a offset property or
>> something?
>>
>> // In the spec on arrays#Setting Dynamic Array Length,
>> // this is the example, but it doesn't work as in the spec...
>>
>> char[] c = a[10..20];
>> // The spec says expanding b.length should expand
>> // in place as a has enough memory and thus overlapping a, but...
>> assert(b.capacity == 0); // capacity is 0, so...
>> b.length = 15;
>> assert(b.capacity == 15); // .. setting length removed it from a..
>> assert(a.ptr == b.ptr); // fails...
>> b[11] = 'x'; // Says a[11] and c[1] should also change..
>> assert(a[11] == 'x'); // fails
>> assert(c[1] == 'x'); // fails
>>
>
> Yep, I noticed that too when going to file the bug :)
>
> see here: http://d.puremagic.com/issues/show_bug.cgi?id=4590
>
> I should take responsibility for not fixing this sooner since the
> runtime used to work this way, but does not since a patch I added in
> 2.041 or 2.042.
>
> Sorry.
>
> -Steve

Thanks again!
Hope spec bugs have high priorities as it's difficult to learn the 
language otherwise. Are the compiler pretty stable, so I can assume most 
bugs are in the spec, or is it the other way around?




More information about the Digitalmars-d mailing list