wrong code generated for inline array of struct with generic type argument
@dueno
Submitted by Daiki Ueno Link to original bug (#684262)
Description
Given the following code:
struct Entry<K,V> { K key; V value; }
int main (string[] args) { const Entry<int,string>[] map = { { 0, "foo" }, { 1, "bar" } }; stdout.printf ("%d %s\n", map[0].key, map[1].value); return 0; }
valac -C generates:
typedef struct _Entry Entry;
struct _Entry { gpointer key; gpointer value; };
static const Entry map[] = {{0, "foo"}, {1, "bar"}}; // (*)
I heard that some compiler does not accept (*)[1]. It seems that a proper cast from integer to pointer (such as "(gintptr)" or "GINT_TO_POINTER") is required.