[Vala] Invalid C code in Interfaces



Hello again!

I seem to have run into a case where valac generates incorrect C code.
I'm sure what I am doing is wrong, but I assume that valac should emit
the error and not gcc.

When I try to compile this snippet,

public interface IFace<G> : Object
{
  public G[] foobar()
  {
    G[] storage = new G[2];
    return storage[0:1];
  }
}

void main(){}

I get this error from gcc:

In function ‘iface_foobar’:
generic.vala.c:54: error: dereferencing pointer to incomplete type

The relevant C code is:

gpointer* iface_foobar (IFace* self, int* result_length1) {
  gpointer* result = NULL;
  gint storage_length1;
  gint _storage_size_;
  gpointer* _tmp0_;
  gpointer* storage;
  gint _tmp1_;
  gpointer* _tmp2_ = NULL;
  gpointer* _tmp3_;
  gpointer* _tmp4_;
  storage = (_tmp0_ = g_new0 (gpointer, 2), storage_length1 = 2,
_storage_size_ = storage_length1, _tmp0_);
  result = (_tmp4_ = (_tmp3_ = (_tmp2_ = storage + 0, _tmp1_ = 1 - 0,
_tmp2_), (_tmp3_ == NULL) ? ((gpointer) _tmp3_) : _vala_array_dup1
(_tmp3_, _tmp1_, self->priv->g_dup_func)), *result_length1 = _tmp1_,
_tmp4_);
  storage = (_vala_array_free (storage, storage_length1,
(GDestroyNotify) NULL), NULL);
  return result;
}

Thanks for your help,
Sam




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]