GNOME Bugzilla – Bug 600315
SOUP_METHOD_* macros incompatible with -Wcast-qual
Last modified: 2018-09-21 16:04:38 UTC
I cannot compile mpdscribble 0.18.1 with libsoup 2.28.1. Before all works fine, but after one of latest libsoup updates lead regression in API. Error message: + make -j1 --silent --no-print-directory cc1: warnings being treated as errors src/http_client_soup.c: In function 'http_client_request': src/http_client_soup.c:140: error: cast discards qualifiers from pointer target type src/http_client_soup.c:163: error: cast discards qualifiers from pointer target type Code: SoupMessage *msg; msg = soup_message_new(SOUP_METHOD_POST, url); // line 140 msg = soup_message_new(SOUP_METHOD_GET, url); // line 163 And there no casting in code, but exists in libsoup's macros (from soup-method.h): #define SOUP_METHOD_POST _SOUP_INTERN_METHOD (POST) #define _SOUP_INTERN_METHOD(method) (_SOUP_ATOMIC_INTERN_STRING (_SOUP_METHOD_##method, #method)) #define _SOUP_ATOMIC_INTERN_STRING(variable, value) ((const char *)(g_atomic_pointer_get (&(variable)) ? (variable) : (g_atomic_pointer_set (&(variable), (gpointer)g_intern_static_string (value)), (variable)))) So, please fix it. Thanks in advance!
changing the summary; the casts in question are not "bad"; they are explicitly allowed by the C standard, and are used here in a semantically correct way. There is a reason that -Wcast-qual is not part of -Wall or even -Wextra, and that's that it causes false positives that cannot always be worked around. (In this case, to avoid the warning we'd need to change the prototype of a function in glib). Using it along with -Werror is just asking for pain. We could work around this by moving part of _SOUP_ATOMIC_INTERN_STRING into a function rather than having it as a macro, so that it gets compiled with libsoup's CFLAGS rather than whatever random CFLAGS the libsoup-consuming application chooses to throw at it.
(note to self: the cast-qual warning happens when casting the const char * return value of g_intern_static_string() to a non-const gpointer as required by g_atomic_pointer_set())
[mass-moving all "UNCONFIRMED" libsoup bugs to "NEW" after disabling the "UNCONFIRMED" status for this product now that bugzilla.gnome.org allows that. bugspam-libsoup-20150210]
-- 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/libsoup/issues/28.