If generic holds struct pointer, returning it returns void* (gpointer) instead.
Submitted by Adam Mizerski
Link to original bug (#690856)
Description
When trying to compile the following code
public class Wrapper<G> : GLib.Object {
private G data;
public void data_set(G data) { this.data = data; }
public G data_get() { return this.data; }
}
public struct Int { public int i; }
int main() {
Int i = {5};
var ptr_i = new Wrapper<Int*>();
ptr_i.data_set(&i);
stdout.printf("%d\n", ptr_i.data_get()->i);
return 0;
}
compilation fails with
test.c: In function ‘_vala_main’:
test.c:216:12: warning: dereferencing ‘void *’ pointer [enabled by default]
test.c:216:20: error: request for member ‘i’ in something not a structure or union
Workaround:
stdout.printf("%d\n", ((Int*)(ptr_i.data_get()))->i);
works as expected.
Version: 0.18.x
Edited by Rico Tzschichholz