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 600315 - SOUP_METHOD_* macros incompatible with -Wcast-qual
SOUP_METHOD_* macros incompatible with -Wcast-qual
Status: RESOLVED OBSOLETE
Product: libsoup
Classification: Core
Component: API
2.28.x
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2009-11-01 16:17 UTC by Slava Semushin
Modified: 2018-09-21 16:04 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Slava Semushin 2009-11-01 16:17: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!
Comment 1 Dan Winship 2009-11-02 17:24:38 UTC
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.
Comment 2 Dan Winship 2009-11-21 22:45:28 UTC
(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())
Comment 3 Dan Winship 2015-02-10 11:57:52 UTC
[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]
Comment 4 GNOME Infrastructure Team 2018-09-21 16:04:38 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/libsoup/issues/28.