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 463781 - G_GNUC_CONST on foo_get_type() functions causes pre-initialisation breakage at -O3
G_GNUC_CONST on foo_get_type() functions causes pre-initialisation breakage a...
Status: RESOLVED DUPLICATE of bug 446565
Product: glib
Classification: Platform
Component: gobject
2.14.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-08-05 22:06 UTC by Ed Catmur
Modified: 2007-08-13 23:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
get_type_G_GNUC_IDEMPOTENT.patch (7.42 KB, patch)
2007-08-11 19:24 UTC, Ed Catmur
none Details | Review

Description Ed Catmur 2007-08-05 22:06:26 UTC
Bug 463730 is caused by gcc -O3 moving a gtk_window_get_type() call up in main() to before GType is initialised.  This is because G_GNUC_CONST is utterly inappropriate for foo_get_type() functions.

G_GNUC_PURE avoids the issue in this particular case, but even so isn't strictly speaking semantically correct.

This is a problem pretty much everywhere.
Comment 1 Ed Catmur 2007-08-05 22:07:27 UTC
Bug 446565 for reference.
Comment 2 Behdad Esfahbod 2007-08-06 21:42:16 UTC
All G_GNUC_CONST marks for get_type() functions should be removed until we get the right attribute defined for us.

Or in the mean time we can define a new macro in glib and start using it.  The macro would initially expand to nothing, but change in the future when the right attribute is added to gcc.
Comment 3 Ed Catmur 2007-08-11 19:24:18 UTC
Created attachment 93505 [details] [review]
get_type_G_GNUC_IDEMPOTENT.patch

Add G_GNUC_IDEMPOTENT (expands to nothing for now) and fix GLib _get_type() declarations.
Comment 4 Ed Catmur 2007-08-12 23:06:43 UTC
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18487 - gcc can't/won't save us from our own stupidity in marking functions const incorrectly.  

> if the user is marking trivial functions const or pure when they clearly
> aren't,
> they deserve what they get :).

We need to stamp out this abuse starting with GLib and GTK+ - it's going to take a while to get application authors to understand that you do NOT put G_GNUC_CONST on get_type() functions.
Comment 5 Tim Janik 2007-08-13 23:27:11 UTC

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