After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 647618 - sizeof(G) broken for G = int
sizeof(G) broken for G = int
Status: RESOLVED DUPLICATE of bug 774713
Product: vala
Classification: Core
Component: Code Generator
unspecified
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-04-13 02:28 UTC by Allison Karlitskaya (desrt)
Modified: 2016-11-30 14:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Allison Karlitskaya (desrt) 2011-04-13 02:28:42 UTC
void print_size<G> () {
    print ("the answer is %lu\n", sizeof (G));
}

void main () {
    print_size<int>();
}

"the answer is 8"
Comment 1 Allison Karlitskaya (desrt) 2011-04-13 02:30:45 UTC
Of course, this is because Vala uses 'sizeof (gpointer)' here.

Worse: glib doesn't have a facility for answering this question correctly.

My particular use case is that I'm trying to write a function to resize arrays and I want to use it with an array of ints.
Comment 2 Luca Bruno 2011-04-16 08:26:47 UTC
GType provides no size information for fundamental types like int through g_type_query?
Comment 3 Al Thomas 2016-11-30 14:29:37 UTC

*** This bug has been marked as a duplicate of bug 774713 ***