Bug 485463 - Possible erroneous warning about aliasing
Possible erroneous warning about aliasing
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-13 12:17 EST by Bruno Wolff III
Modified: 2009-02-21 08:59 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-02-21 08:59:30 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Source file pointed to by the error message. (78.88 KB, text/plain)
2009-02-13 12:17 EST, Bruno Wolff III
no flags Details
.s file (659.78 KB, text/plain)
2009-02-13 13:23 EST, Bruno Wolff III
no flags Details
The ai.ii file. (2.02 MB, text/plain)
2009-02-14 11:45 EST, Bruno Wolff III
no flags Details
New ai.ii (2.02 MB, text/plain)
2009-02-18 00:33 EST, Bruno Wolff III
no flags Details

  None (edit)
Description Bruno Wolff III 2009-02-13 12:17:04 EST
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:
Comment 1 Jakub Jelinek 2009-02-13 12:30:26 EST
That's not sufficient, please rerun the g++ command with -save-temps and attach
ai.ii instead.
Comment 2 Bruno Wolff III 2009-02-13 13:23:40 EST
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
Comment 3 Jakub Jelinek 2009-02-13 14:10:55 EST
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".
Comment 4 Bruno Wolff III 2009-02-13 14:27:25 EST
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?
Comment 5 Jakub Jelinek 2009-02-13 14:51:06 EST
Certainly avoid ccache, sure.
Comment 6 Bruno Wolff III 2009-02-14 11:45:09 EST
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.
Comment 7 Bruno Wolff III 2009-02-17 17:12:22 EST
I see that a fix for this is going into -20. I'll retest tomorrow night.
Comment 8 Bruno Wolff III 2009-02-18 00:33:41 EST
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
Comment 9 Bruno Wolff III 2009-02-18 10:30:21 EST
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.)
Comment 10 Bruno Wolff III 2009-02-21 08:59:30 EST
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.

Note You need to log in before you can comment on or make changes to this bug.