ERROR - "cannot implicitly convert expression (s) of type int[3u] to int*"

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Fri Jun 18 19:09:46 PDT 2010


On Fri, 18 Jun 2010 08:41:17 -0700, Justin Spahr-Summers 
<Justin.SpahrSummers at gmail.com> wrote:
> 
> On Fri, 18 Jun 2010 01:25:32 -0400, Chick Corea <chick.zcorea at gmail.com> 
> wrote:
> > Those are the result of code that I pulled directly from the D v1 docs from
> > 
> >     http://www.digitalmars.com/d/1.0/arrays.html
> > 
> > Specifically, the code is this.
> > 
> >         int* p;
> >         int[3] s;
> >         int[] a;
> >         p = s;
> >         p = a;
> > 
> 
> I can't speak as to why the D2 code doesn't work, but this example in 
> the documentation is flat out wrong. To assign a D array to a pointer, 
> you must use the .ptr property, so that the correct code is actually:
> 
>  int* p;
>  int[3] s;
>  int[] a;
>  p = s.ptr;
>  p = a.ptr;
> 
> Hope this clears things up.

I followed up last night, but my post didn't show up until this morning. 
Sorry for the redundant answer! :X


More information about the Digitalmars-d-learn mailing list