Created attachment 331846 [details] Source file pointed to by the error message. Description of problem: When building Wesoth with gcc 4.4 I get a warning about improper aliasing that I do not get with gcc 4.3. I asked on the Wesnoth list and someone there gave an opinion that the code looked correct. The error message is: mv -f $depbase.Tpo $depbase.Po depbase=`echo ai.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_REVISION -I../intl -I../intl -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DWESNOTH_PATH=\"/home/wesnoth/wesnoth-1.5/share/wesnoth\" -DLOCALEDIR=\"translations\" -DHAS_RELATIVE_LOCALEDIR=1 -DFIFODIR=\"/home/wesnoth/wesnoth-1.5/var/run/wesnothd\" -DWESNOTH_PREFIX=\"/home/wesnoth/wesnoth-1.5\" -DHAVE_PYTHON -I/usr/include/python2.6 -O2 -W -Wall -ansi -g -DDEBUG -Werror -Wno-unused -Wno-sign-compare -DDISABLE_POOL_ALLOC -D_X11 -DPREFERENCES_DIR=\".wesnoth-1.5\" -I/usr/include -MT ai.o -MD -MP -MF $depbase.Tpo -c -o ai.o ai.cpp &&\ mv -f $depbase.Tpo $depbase.Po cc1plus: warnings being treated as errors ai.cpp: In member function ‘virtual void ai::analyze_potential_recruit_movements()’: ai.cpp:1905: error: dereferencing pointer ‘<anonymous>’ does break strict-aliasing rules /usr/lib/gcc/i386-redhat-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_tree.h:259: note: initialized from here make[2]: *** [ai.o] Error 1 make[2]: Leaving directory `/home/bruno/wesnoth-1.5/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/bruno/wesnoth-1.5' make: *** [all] Error 2 This is with revsion 32796 of the wesnoth trunk (version 1.5.x). I'll attach the ai.cpp file in case that alone is enough to make a determination. Version-Release number of selected component (if applicable): gcc-4.4.0-0.17.i386 How reproducible: 100% Steps to Reproduce: 1. Check out and build wesnoth 2. 3. Actual results: Expected results: Additional info:
That's not sufficient, please rerun the g++ command with -save-temps and attach ai.ii instead.
Created attachment 331853 [details] .s file I tried that and started having .s files left behind. For now I have included one of those. Is there some option used below which blocks this from working as expected: mv -f $depbase.Tpo $depbase.Po depbase=`echo ai.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_REVISION -I../intl -I../intl -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DWESNOTH_PATH=\"/home/wesnoth/wesnoth-1.5/share/wesnoth\" -DLOCALEDIR=\"translations\" -DHAS_RELATIVE_LOCALEDIR=1 -DFIFODIR=\"/home/wesnoth/wesnoth-1.5/var/run/wesnothd\" -DWESNOTH_PREFIX=\"/home/wesnoth/wesnoth-1.5\" -DHAVE_PYTHON -I/usr/include/python2.6 -O2 -W -Wall -ansi -g -DDEBUG -save-temps -Werror -Wno-unused -Wno-sign-compare -DDISABLE_POOL_ALLOC -D_X11 -DPREFERENCES_DIR=\".wesnoth-1.5\" -I/usr/include -MT ai.o -MD -MP -MF $depbase.Tpo -c -o ai.o ai.cpp &&\ mv -f $depbase.Tpo $depbase.Po cc1plus: warnings being treated as errors ai.cpp: In member function ‘virtual void ai::analyze_potential_recruit_movements()’: ai.cpp:1905: error: dereferencing pointer ‘<anonymous>’ does break strict-aliasing rules /usr/lib/gcc/i386-redhat-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_tree.h:259: note: initialized from here make[2]: *** [ai.o] Error 1 make[2]: Leaving directory `/home/bruno/wesnoth-1.5/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/bruno/wesnoth-1.5' make: *** [all] Error 2
ai.s is useless as well, I really need ai.ii, which -save-temps generates as well. Alternatively you could replace "-c -o ai.o" with "-E -o ai.ii".
I didn't get any *.ii files, so I couldn't include any. I am not at the location where I can test this again right now. But I'll try again tonight or tomorrow. If the -E option doesn't work, is there anything else I should look at? Would having ccache installed affect any of this?
Certainly avoid ccache, sure.
Created attachment 331929 [details] The ai.ii file. I uninstalled ccache and ran the build script again and got the *.ii files. It probably doesn't matter, but this came from wesnoth svn version 32805.
I see that a fix for this is going into -20. I'll retest tomorrow night.
Created attachment 332338 [details] New ai.ii I was able to test -20 tonight and there is still a complaint about aliasing, but the output is different. g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DHAVE_REVISION -I../intl -I../intl -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DWESNOTH_PATH=\"/home/wesnoth/wesnoth-1.5/share/wesnoth\" -DLOCALEDIR=\"translations\" -DHAS_RELATIVE_LOCALEDIR=1 -DFIFODIR=\"/home/wesnoth/wesnoth-1.5/var/run/wesnothd\" -DWESNOTH_PREFIX=\"/home/wesnoth/wesnoth-1.5\" -DHAVE_PYTHON -I/usr/include/python2.6 -O2 -W -Wall -ansi -g -DDEBUG -save-temps -Werror -Wno-unused -Wno-sign-compare -DDISABLE_POOL_ALLOC -D_X11 -DPREFERENCES_DIR=\".wesnoth-1.5\" -I/usr/include -MT ai.o -MD -MP -MF $depbase.Tpo -c -o ai.o ai.cpp &&\ mv -f $depbase.Tpo $depbase.Po cc1plus: warnings being treated as errors map_location.hpp: In member function ‘virtual void ai::move_leader_after_recruit(const std::multimap<map_location, map_location, std::less<map_location>, std::allocator<std::pair<const map_location, map_location> > >&, const std::multimap<map_location, map_location, std::less<map_location>, std::allocator<std::pair<const map_location, map_location> > >&, const std::multimap<map_location, map_location, std::less<map_location>, std::allocator<std::pair<const map_location, map_location> > >&)’: map_location.hpp:74: error: dereferencing pointer ‘__x.1948’ does break strict-aliasing rules map_location.hpp:74: error: dereferencing pointer ‘__x.1948’ does break strict-aliasing rules map_location.hpp:74: error: dereferencing pointer ‘__x.1948’ does break strict-aliasing rules /usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_tree.h:530: note: initialized from here map_location.hpp:74: error: dereferencing pointer ‘__x.1948’ does break strict-aliasing rules map_location.hpp:74: error: dereferencing pointer ‘__x.1948’ does break strict-aliasing rules map_location.hpp:74: error: dereferencing pointer ‘__x.1948’ does break strict-aliasing rules /usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_tree.h:530: note: initialized from here make[2]: *** [ai.o] Error 1 make[2]: Leaving directory `/home/bruno/wesnoth-1.5/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/bruno/wesnoth-1.5' make: *** [all] Error 2
After looking at this new message more carefully, it looks like it is warning about different code than the original one. So I need to look and see if the error appears to be correct or not. (It wasn't reported by gcc 4.3 though.)
These warnings are both gone now. I may have another one for you, but I'll file a separate bug if it looks to be a mistake.