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 115723 - GCC 3.3 Compile Warnings/Failure
GCC 3.3 Compile Warnings/Failure
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: Build
cvs (head)
Other Linux
: Normal normal
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
Depends on:
Blocks:
 
 
Reported: 2003-06-22 14:50 UTC by James Cape
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix w/o -Wno-strict-aliasing (14.04 KB, patch)
2003-06-22 21:43 UTC, James Cape
none Details | Review

Description James Cape 2003-06-22 14:50:23 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.
Comment 1 James Cape 2003-06-22 21:43:24 UTC
Created attachment 17694 [details] [review]
Patch to fix w/o -Wno-strict-aliasing
Comment 2 James Cape 2003-06-22 21:44:10 UTC
I can commit this if it's desired.
Comment 3 Christophe Fergeau 2003-06-22 21:53:47 UTC
I tend to prefer the -Wno-strict-aliasing that you removed from
configure.in instead of those ugly union workarounds for a false
warning...
Comment 4 James Cape 2003-06-22 22:15:29 UTC
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 :-)).
Comment 5 Christophe Fergeau 2003-06-25 17:57:57 UTC
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.
Comment 6 Alexander Larsson 2003-06-30 13:43:15 UTC
I don't understand. CVS is using -Wno-strict-aliasing already. Is this
not working?
Comment 7 James Cape 2003-06-30 14:38:42 UTC
The issue is that I used to set CFLAGS="-Wall ..." in ~/.bash_profile,
which caused the breakage.
Comment 8 Alexander Larsson 2003-07-04 12:58:19 UTC
Ah. Then i'll considered this bug "fixed".