r18612 - gnucash/trunk/src - Corrections to r18610 to permit compiling against older versions of glib
John Ralls
jralls at ceridwen.us
Tue Feb 9 11:34:42 EST 2010
On Feb 9, 2010, at 5:54 AM, Derek Atkins wrote:
> John,
>
> I think you missed my main point, which is that your new code *wont
> work* because it never assigns the correct variable. More details
> inline...
>
> John Ralls <jralls at ceridwen.us> writes:
>
> [snip]
>>>> - gnc_numeric *key;
>>>> + gnc_numeric *key = NULL;
>>>> + gpointer pkey = (gpointer)key;
>
> Okay, so key is now NULL, which is fine. But then the second line
> just assigns pkey to the VALUE of key, which means pkey == NULL.
Got it. That's my GCE.
[...]
>
>> The problem in both cases was that gcc-4.1.3 puked on casting the address of key to a gpointer*:
>> cc1: warnings being treated as errors
>> window-autoclear.c: In function ‘gnc_autoclear_window_ok_cb’:
>> window-autoclear.c:171: warning: dereferencing type-punned pointer will break strict-aliasing rules
>> (And, of course, the same for split.)
>
> Fair enough. I wonder if we actually NEED the explicit cast?
> If we do then we need to come up with another way of doing it,
> maybe by re-assigning after the fill-in call.
Yes, otherwise gcc will whine about passing an incompatible pointer.
Googling 'gpointer strict-aliasing' produced http://www.hulver.com/scoop/story/2004/4/25/13713/0715,
which recommends reassigning, just as you say. I'll add that (along with a stern comment) shortly.
Regards,
John Ralls
More information about the gnucash-devel
mailing list