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 794635 - gmacros: Don't define bogus __has_* macros
gmacros: Don't define bogus __has_* macros
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2018-03-23 18:15 UTC by Nirbheek Chauhan
Modified: 2018-03-26 11:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gmacros: Don't define bogus __has_* macros (4.57 KB, patch)
2018-03-23 18:15 UTC, Nirbheek Chauhan
none Details | Review
gmacros: Don't define bogus __has_* macros (4.57 KB, patch)
2018-03-23 18:17 UTC, Nirbheek Chauhan
none Details | Review
gmacros: Don't define bogus __has_* macros (4.44 KB, patch)
2018-03-26 11:28 UTC, Nirbheek Chauhan
committed Details | Review

Description Nirbheek Chauhan 2018-03-23 18:15:15 UTC
This pollutes the reserved compiler namespace and breaks applications trying to do their own feature detection. For instance, this falsely detects that alloca is not a builtin on gcc:

    #include <glib.h>
    #if defined(__has_builtin)
    # if !__has_builtin(alloca)
    #  error "wtf glib?"
    # endif
    #else
    /* version-checking to determine alloca type */
    #endif

Instead, define our own g_macro__has_* versions that have the behaviour that we need.
Comment 1 Nirbheek Chauhan 2018-03-23 18:15:20 UTC
Created attachment 370061 [details] [review]
gmacros: Don't define bogus __has_* macros

This pollutes the reserved compiler namespace and breaks applications
trying to do their own feature detection. For instance, this falsely
detects that alloca is not a builtin on gcc:

    #include <glib.h>
    #if defined(__has_builtin)
    # if !__has_builtin(alloca)
    #  error "wtf glib?"
    # endif
    #else
    /* version-checking to determine alloca existence */
    #endif

Instead, define our own g_macro__has_* versions that have the
behaviour that we need.
Comment 2 Nirbheek Chauhan 2018-03-23 18:17:54 UTC
Created attachment 370062 [details] [review]
gmacros: Don't define bogus __has_* macros

This pollutes the reserved compiler namespace and breaks applications
trying to do their own feature detection. For instance, this falsely
detects that alloca is not a builtin on gcc:

    #include <glib.h>
    #if defined(__has_builtin)
    # if !__has_builtin(alloca)
    #  error "wtf glib?"
    # endif
    #else
    /* version-checking to determine alloca existence */
    #endif

Instead, define our own g_macro__has_* versions that have the
behaviour that we need.
Comment 3 Nirbheek Chauhan 2018-03-23 18:19:26 UTC
Sorry about the bogus repetition, git-bz has some weird corner-cases. Do tell me if I should file this as a PR on gitlab instead, wasn't sure what the status was!
Comment 4 Philip Withnall 2018-03-26 09:41:23 UTC
Review of attachment 370062 [details] [review]:

::: glib/gmacros.h
@@ +119,3 @@
+ */
+
+#define g_macro_eval_false(x) 0

Why add g_macro_eval_false()? Why not just define the other macros to 0 directly?
Comment 5 Nirbheek Chauhan 2018-03-26 11:28:58 UTC
Created attachment 370145 [details] [review]
gmacros: Don't define bogus __has_* macros

I thought it would avoid any pre-processor corner-cases to define it like that, but I can't actually find any, so here's an updated patch.
Comment 6 Philip Withnall 2018-03-26 11:40:13 UTC
Review of attachment 370145 [details] [review]:

OK, please push to master.
Comment 7 Nirbheek Chauhan 2018-03-26 11:44:45 UTC
Thanks!

Attachment 370145 [details] pushed as e2bd6a6 - gmacros: Don't define bogus __has_* macros