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 446565 - Idempotent/const get_type() function declarations
Idempotent/const get_type() function declarations
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Tim Janik
gtkdev
: 64994 463730 463781 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-06-12 00:29 UTC by Behdad Esfahbod
Modified: 2018-05-24 11:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
get_type_G_GNUC_IDEMPOTENT.patch (7.42 KB, patch)
2007-08-14 07:10 UTC, Ed Catmur
none Details | Review

Description Behdad Esfahbod 2007-06-12 00:29:07 UTC
I know that technically speaking those are not G_GNUC_CONST, but we've been marking them as such in other places.
Comment 1 Tim Janik 2007-06-14 20:44:22 UTC
please provide a patch that can be evaluated for discussion/inclusion (or i'll drastically NEEDINFO this bug to get rid of it ;)
Comment 2 Behdad Esfahbod 2007-06-14 21:08:00 UTC
So given your comment in bug 446874 (g_type_ensure()), should I take it that this is in fact WONTFIX too?  Cause if marking get_type() functions G_GNUC_CONST is wrong, there's no point in having a patch for discussion.
Comment 3 Tim Janik 2007-06-14 23:55:16 UTC
(In reply to comment #2)
> So given your comment in bug 446874 (g_type_ensure()), should I take it that
> this is in fact WONTFIX too?  Cause if marking get_type() functions
> G_GNUC_CONST is wrong, there's no point in having a patch for discussion.

no, i personally dislike GNUC_CONST for _get_type because it is a gcc abuse and that effectively causes problems in actual practice. 
however, others want the optimization so much that they are willing to patch up for the nasty side effects, even in third-party apps after invalid GNUC_CONST flagging was added to glib/gtk functions. using the same argument, glib-mkenum could support GNUC_CONST optionally (using a command line argument, because it introduces potential breakage).
ideally however, someone persues introduction of __attribute__((constant_registry)) as suggested in bug 446874. that way all current get_type GNUC_CONST cases could be fixed, no workarounds need to be added anywhere and glib-mkenum could support flagging unconditionally.
Comment 4 Tim Janik 2007-06-14 23:57:24 UTC
(In reply to comment #3)
> ideally however, someone persues introduction of
> __attribute__((constant_registry)) as suggested in bug 446874.

or "__attribute__ ((value_constructor))", i.e. anything outlining that the first call ever must not be skipped and subsequent calls may be freely optimized.
Comment 5 Behdad Esfahbod 2007-07-27 06:34:21 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > ideally however, someone persues introduction of
> > __attribute__((constant_registry)) as suggested in bug 446874.
> 
> or "__attribute__ ((value_constructor))", i.e. anything outlining that the
> first call ever must not be skipped and subsequent calls may be freely
> optimized.

Submitted: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32911
Called it __attribute__ ((idempotent)) though.
Comment 6 Tim Janik 2007-08-13 23:26:13 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > or "__attribute__ ((value_constructor))", i.e. anything outlining that the
> > first call ever must not be skipped and subsequent calls may be freely
> > optimized.
> 
> Submitted: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32911
> Called it __attribute__ ((idempotent)) though.

thanks, this bug is effectively the main blocker on gcc support for __attribute__ ((idempotent)) now, and others will be marked as duplicates.
Comment 7 Tim Janik 2007-08-13 23:27:11 UTC
*** Bug 463781 has been marked as a duplicate of this bug. ***
Comment 8 Tim Janik 2007-08-13 23:27:30 UTC
*** Bug 463730 has been marked as a duplicate of this bug. ***
Comment 9 Ed Catmur 2007-08-14 07:10:35 UTC
Created attachment 93629 [details] [review]
get_type_G_GNUC_IDEMPOTENT.patch

Reattaching patch from merged bug so it doesn't get lost.

This patch introduces and documents a G_GNUC_IDEMPOTENT macro, currently expanding to nothing, and applies it to all get_type functions in the glib tarball.

We should apply this to glib now in advance of __attribute__((idempotent)) being added to gcc; this would allow get_type() functions elsewhere to be fixed.
Comment 10 Tim Janik 2007-08-14 08:04:55 UTC
(In reply to comment #9)
> Created an attachment (id=93629) [edit]
> get_type_G_GNUC_IDEMPOTENT.patch
> 
> Reattaching patch from merged bug so it doesn't get lost.
> 
> This patch introduces and documents a G_GNUC_IDEMPOTENT macro, currently
> expanding to nothing, and applies it to all get_type functions in the glib
> tarball.
> 
> We should apply this to glib now in advance of __attribute__((idempotent))
> being added to gcc; this would allow get_type() functions elsewhere to be
> fixed.

i don't really want to apply anything API-wise to glib until we can be reasonably sure that future gcc versions will have this. (so if you want to get this patch in, what you really need is to get the gcc people to promise adding ((idempotent)) to future versions and with that name.)
Comment 11 Philip Withnall 2017-09-14 09:48:48 UTC
*** Bug 64994 has been marked as a duplicate of this bug. ***
Comment 12 Philip Withnall 2017-09-14 09:57:25 UTC
I’ve filed a bug against Clang with the same request, here: https://bugs.llvm.org/show_bug.cgi?id=34600

The GCC bug report is here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32911
Comment 13 GNOME Infrastructure Team 2018-05-24 11:03:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/97.