Formal Review of std.range.ndslice

Stefan Frijters via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 13 13:24:36 PST 2015


On Sunday, 13 December 2015 at 15:59:19 UTC, Ilya Yaroshenko 
wrote:
> Could you please post reduced code example that caused dmd to 
> segfault?

Took dustmite about 6 hours to reduce, and then I went at it 
manually for a bit, so this is the smallest I could get it:

import std.experimental.ndslice;

int main() {
   Field force;
   foreach(p, e; force) e;
}

struct Field {
   alias arr this;
   Slice!(3, double*) arr;
}

Compiled with dmd 2.069.1 via dub build:

{
     "name": "dlbc",
     "sourcePaths": ["src"],
     "dependencies": {
         "dip80-ndslice": "~>0.8.3",
     },
}

dip80-ndslice 0.8.3: target for configuration "library" is up to 
date.
dlbc ~master: building configuration "application"...
Segmentation fault
dmd failed with exit code 139.

Since it's a segfault in the compiler, should I put it on 
Bugzilla too?

> 2D way: &slice[0, 0]   or   &(slice.front.front());
>
> ND way: &(slice.byElement.front())
>
> Note: Comparing with unstandard  there is no guarantee that the 
> first element in a ndarray is the first element in memory. 
> `reversed` and `allReversed` should not be used to preserve 
> strides positive.

Hm, I assumed the underlying array would be a single block of 
data and then a bunch of pointers would be used to keep track of 
any slices. I'll try to figure out how to give the data to C then 
(for MPI and HDF5, to be exact).


More information about the Digitalmars-d mailing list