GNOME Bugzilla – Bug 115723
GCC 3.3 Compile Warnings/Failure
Last modified: 2004-12-22 21:47:04 UTC
GCC 3.3 includes -fstrict-aliasing with -O2 optimizations. Among other things, this generates warnings for things like (gpointer *) &widget_ptr in function arguments. Because GnomeVFS uses -O2 -Wall -Werror, it currently barfs the compile. The proper solution is the use a union: union { GtkWidget *widget; gpointer ptr; } widget_ptr; and then use &widget_ptr.ptr in the function args. I'm working on a patch for this.
Created attachment 17694 [details] [review] Patch to fix w/o -Wno-strict-aliasing
I can commit this if it's desired.
I tend to prefer the -Wno-strict-aliasing that you removed from configure.in instead of those ugly union workarounds for a false warning...
I understand, I just think that the -fstrict-aliasing optimization is one that gnome-vfs can take advantage of without too much of a hassle. Also, AFAIK it's not a false warning: In my own project, I used gpointer **ptr = &some_var and passed ptr as the argument. It caused code which worked before to freeze the app. At any rate, the correct flag should probably be -fno-strict-aliasing, not -Wno-strict-aliasing (my CFLAGS env var contains -Wall, which is why I wasted all this time :-)).
We don't want to disable the optimization, we only want to get rid of the warning, and -Wno-strict-aliasing is the correct way to achieve that. Strict aliasing can cause problem if you do something like what you described and then try to dereference the pointer. As long as you are not dereferencing it, things should be ok.
I don't understand. CVS is using -Wno-strict-aliasing already. Is this not working?
The issue is that I used to set CFLAGS="-Wall ..." in ~/.bash_profile, which caused the breakage.
Ah. Then i'll considered this bug "fixed".