patch for gcc 3.3 compile warnings, pricedb

Herbert Thoma tma at iis.fhg.de
Sun Apr 13 20:32:55 CDT 2003


Derek Atkins schrieb:
> 
> Herbert,
> 
> I've been looking over this patch.  One problem is that is
> appears to also include your price-db patch, so I expect it
> wont apply cleanly.  But I can work around that.

Sorry for the mixing of the two patches. I was just in the middle
of my pricedb/currency conversion work when I changed to
SuSE 8.2/gcc 3.3 ...

> I also find it odd that gcc-3.3 now requires you to set a temp
> variable in order to pass a pointer:
> 
>    gchar * keyptr=NULL;
>    gchar * valptr=NULL;
> +  gchar ** p_keyptr = &keyptr;
> +  gchar ** p_valptr = &valptr;
> 
>    g_return_if_fail (actionid != NULL);
> 
>    if (!g_hash_table_lookup_extended(gnc_html_action_handlers,
>                                      actionid,
> -                                    (gpointer *)&keyptr,
> -                                    (gpointer *)&valptr))
> +                                    (gpointer *)p_keyptr,
> +                                    (gpointer *)p_valptr))
> 
> Are you sure this is really necessary?  What's the actual compiler
> warning here?  Did you test to see what happens if you just remove the
> (gpointer *) cast with the original &keyptr?

The warning is:
warning: dereferencing type-punned pointer will break strict-aliasing rules

if I remove the (gpointer *) cast I get:
warning: passing arg 3 of 'g_hash_table_lookup_extended' from incompatible pointer type

> I'm not adverse to applying this patch (indeed, I'm applying it now).
> I'm just wondering if this particular coding style is actually
> necessary.

I don't like this either but it seems to be a gcc 3.3 problem.

 Herbert.

> -derek
> 
-- 
Herbert Thoma
FhG-IIS A, Studio Department
Am Weichselgarten 3, 91058 Erlangen, Germany
Phone: +49-9131-776-323
Fax:   +49-9131-776-399
email: tma at iis.fhg.de
www: http://www.iis.fhg.de/


More information about the gnucash-patches mailing list