Is this a bug in iota?

Brad Anderson eco at gnuk.net
Wed Apr 18 20:45:54 PDT 2012


On Thursday, 19 April 2012 at 03:37:00 UTC, bearophile wrote:
> Brad Anderson:
>> You can popFront() for as long as you want well passed the 
>> length. Obviously popping off the front of a zero length range 
>> isn't valid but I would have expected a range violation to 
>> occur rather than it to silently continuing the series with a 
>> wrapped around length.
>
> I think it's a matter of design and it's a matter of having an 
> alternative Phobos release that contains asserts too. Adding 
> the test slows down something (iota) that must be as fast as 
> possible. And currently asserts are removed from the compiled 
> Phobos...
>
> Bye,
> bearophile

Since iota is a template doesn't that mean it's not in phobos.lib 
but rather generated and built into my application?  I'm not 
compiling in release mode so I would think any bounds checking it 
had would remain (I haven't yet looked at the source to see if 
there are any checks).  I can definitely see stripping any bounds 
checking from a release build, of course.

Doing this same thing to a slice of an array does throw a Range 
Violation exception in release (and asserts in debug).

Regards,
Brad Anderson


More information about the Digitalmars-d-learn mailing list