Thomas Koenig <tkoenig at gcc dot> changed:

           What    |Removed                     |Added
                 CC|                            |pault at gcc dot

--- Comment #22 from Thomas Koenig <tkoenig at gcc dot> ---

What we _could_ do with our array descriptors is to cast them to
a pointer containing a flexible array member, i.e.

struct type_descr {
  type *base_addr;
  size_t offset;
  dtype_type dtype;
  index_type span;
  descriptor_dimension dim[];

which would make all our function calls equal.

I have lightly tested the concept with a C program, i.e.


struct Xflex { int n; int a[]; };

int foo (struct Xflex *f)
  int i;
  int s;
  s = 0;
  for (i=0; i<f->n; i++)
    s += f->a[i];

  return s;


#include <stdio.h>

struct Xflex { int n; int a[]; };
struct X2 { int n; int a[2]; };

struct X2 x;

int foo (struct Xflex *f);

int main(void)
  x.n = 2;
  x.a[0] = 1;
  x.a[1] = 3;
  printf("%d\n", foo((struct Xflex *) &x));

which seems to work.

Reply via email to