On Monday, 28 April 2014 at 08:58:41 UTC, Andrey wrote:
Could anyone please explain to me, why do I have error message on this piece of code?

alias short Type1;
alias Type1[100]* Type2; // pointer to an array
struct Type3
{
        Type2 f
}
void foo()
{
   Type3* b;
   Type1  d;
d = b.f[10]; // compilation error: cannot implicitly convert expression ((*b).f[10]) of type short[100] to short
   d = b.f[0][10]; // ok
}

Thank you in advance

not a bug.

b.f[10] is indexing the pointer to the array, not the array itself.

b.f[0][10] is indexing the array (with the 10), but I would argue it is better to write *(b.f)[10] so as to be clear that f is not an array.

What is the reason you are using a pointer to a struct containing a pointer to a static array? It's often not necessary to work like that.

Reply via email to