GNOME Bugzilla – Bug 594508
wrong type for SOUP_URI_SCHEME_HTTP and SOUP_URI_SCHEME_HTTPS, g++ 4.4 compiler error
Last modified: 2009-09-08 17:08:40 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.
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)
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.
fixed in git