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 594508 - wrong type for SOUP_URI_SCHEME_HTTP and SOUP_URI_SCHEME_HTTPS, g++ 4.4 compiler error
wrong type for SOUP_URI_SCHEME_HTTP and SOUP_URI_SCHEME_HTTPS, g++ 4.4 compil...
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: API
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2009-09-08 14:52 UTC by Patrick Ohly
Modified: 2009-09-08 17:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Patrick Ohly 2009-09-08 14:52:18 UTC
With g++ 4.4, code like this fails to compile (found in SyncEvolution):

            SoupURI *uri = soup_message_get_uri(message.get());
=>          if (!strcmp(uri->scheme, SOUP_URI_SCHEME_HTTPS)) {
                SE_THROW_EXCEPTION(TransportException, "SSL certificate checking requested, but no CA certificate file configured");
            }

SoupTransportAgent.cpp:119: error: invalid conversion from 'void*' to 'const char*'
SoupTransportAgent.cpp:119: error:   initializing argument 2 of 'int strcmp(const char*, const char*)'

One could argue that the code should have used "uri->scheme == SOUP_URI_SCHEME_HTTPS", but in other cases a strcmp() against SOUP_URI_SCHEME_HTTPS might be impossible to avoid (for example, after a strcpy of uri->scheme).

The root cause of this is the following line, taken from the latest libsoup master branch as of today:
libsoup/soup-uri.h:extern gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;

This should be a gchar instead of gpointer.
Comment 1 Dan Winship 2009-09-08 15:30:00 UTC
actually, the backing variables need to be gpointers to avoid "strict aliasing" warnings (see bug 588771)

does this fix things for you:

diff --git a/libsoup/soup-misc.h b/libsoup/soup-misc.h
index c36712c..e40fa91 100644
--- a/libsoup/soup-misc.h
+++ b/libsoup/soup-misc.h
@@ -36 +36 @@ gboolean           soup_str_case_equal       (gconstpointer v1,
-#define _SOUP_ATOMIC_INTERN_STRING(variable, value) (g_atomic_pointer_get (&(variable)) ? (variable) : (g_atomic_pointer_set (&(variable), (gpointer)g_intern_static_string (value)), (variable)))
+#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))))

(um... bugzilla will probably line-wrap and mangle that, but basically, putting "(const char *)" before the value of the macro)
Comment 2 Patrick Ohly 2009-09-08 17:03:15 UTC
I don't quite follow the comment about struct aliasing warning, but if you say so ;-)

Yes, putting a (const char *) in front of the whole expression would also solve the problem.
Comment 3 Dan Winship 2009-09-08 17:08:40 UTC
fixed in git