GNOME Bugzilla – Bug 463781
G_GNUC_CONST on foo_get_type() functions causes pre-initialisation breakage at -O3
Last modified: 2007-08-13 23:27:11 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.
Bug 446565 for reference.
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.
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.
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.
*** This bug has been marked as a duplicate of 446565 ***