Bug 140918 - bzflag weird behavior with -fstrict-aliasing
Bug#: 140918 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: games@gentoo.org Reported By: andreas@tpwch.com
Component: Games
URL: 
Summary: bzflag weird behavior with -fstrict-aliasing
Keywords:  
Status Whiteboard: 
Opened: 2006-07-18 07:29 0000
Description:   Opened: 2006-07-18 07:29 0000
I've been having some problems with bzflag lately, that is that if I shoot
someone I won't hit them, and the other persons doesn't see my shots. After
googling around a bit I found this upstream bug posted over a year ago, but
nothing has happened after that, so the devs must have missed it:
http://sourceforge.net/tracker/index.php?func=detail&aid=1191085&group_id=3248&atid=103248

The person who reported that says that it will get this weird behavior with gcc
4.0 and -O2 or -fstrict-aliasing. I have found that it also happens with -O3.
And sure enough, downgrading the cflags to -O1 fixed the problem.

If the bug is caused by >=-O2 implying -fstrict-aliasing then the most correct
workaround would be to add -fno-strict-aliasing, otherwise I guess you'll have
to filter out -O2 -O3 and -Os. I have posted a comment in the upstream bug, and
hopefully it'll get some attention from the upstream developers so they can
provide a proper fix

My emerge info:
Portage 2.1.1_pre3-r1 (default-linux/amd64/2006.0, gcc-4.1.1/amd64-vanilla,
glibc-2.4-r3, 2.6.17-gentoo-r2-tpc1 x86_64)
=================================================================
System uname: 2.6.17-gentoo-r2-tpc1 x86_64 AMD Athlon(tm) 64 X2 Dual Core
Processor 4400+
Gentoo Base System version 1.12.1
ccache version 2.4 [enabled]
app-admin/eselect-compiler: 2.0.0_rc2-r1
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r2
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17
sys-devel/gcc-config: 2.0.0_rc1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.16
ACCEPT_KEYWORDS="amd64 ~amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -mtune=athlon64 -msse3 -O3 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/eselect/compiler
/etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-march=athlon64 -mtune=athlon64 -msse3 -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig ccache confcache distlocks fixpackages metadata-transfer
parallel-fetch sandbox sfperms strict"
GENTOO_MIRRORS="http://ds.thn.htu.se/linux/gentoo
http://ftp.du.se/pub/os/gentoo http://distfiles.gentoo.org
http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LANG="sv_SE.ISO-8859-1"
LC_ALL="sv_SE.ISO-8859-1"
LINGUAS="sv"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress
--force --whole-file --delete --delete-after --stats --timeout=180
--exclude='/distfiles' --exclude='/local' --exclude='/pac
kages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="amd64 GAPING_SECURITY_HOLE X a52 aac aalib acpi alsa amr ao apache apache2
ares asf authfile avi bash-completion bcmath berkdb bluetooth browserplugin
bzip2 cairo cddb cdparanoia cli crypt cups curl 
curlwrappers custom-cflags dbus dga dlloader dmi dri dv dvd dvdread encode faad
fam ffmpeg flac fontconfig foomaticdb fortran ftp gd gdbm gif gimp glibc-omitfp
glitz gnutls gphoto2 gs gtk gtk2 hal hub idn
 imagemagick inkjar iontruetype ithreads java javascript jce jpeg kqemu latin1
lcms libcaca libg++ live logitech-mouse logrotate lua mad mikmod mmap mng
modplug mp3 mp4 mpeg musepack musicbrainz mysql ncu
rses nls noflagstrip nptl nptlonly nsplugin nvidia offensive ogg opengl
opensslcrypt pam panel-plugin parse-clocks pcre pda pdf pdflib perl
pg-intdatetime php png pwdb python quicktime rdesktop readline r
ewrite rtc ruby sasl scanner sdl session shaper simplexml slang smp sockets
speex spell sql ssl subversion svg symlink syslog theora threads thumbnail
thunar-vfs tiff timidity truetype truetype-fonts type
1-fonts udev usb vcd vchroot vim-pager vim-with-x vorbis vroot wxwindows x264
xanim xcomposite xml xml2 xorg xpm xv xvid xvmc zip zlib elibc_glibc
input_devices_keyboard input_devices_mouse kernel_linux l
inguas_sv userland_GNU video_cards_nv video_cards_nvidia"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LDFLAGS,
PORTAGE_RSYNC_EXTRA_OPTS

------- Comment #1 From Andreas Eriksson 2006-07-18 07:40:48 0000 -------
*** Bug 140919 has been marked as a duplicate of this bug. ***

------- Comment #2 From SpanKY 2006-07-19 19:00:58 0000 -------
bzflag itself should fix its code or force -fno-strict-aliasing in their build
system

in the meantime, an 'append-flags -fno-strict-aliasing' in the ebuild should be
ok

------- Comment #3 From Christopher Sean Morrison 2006-10-27 13:37:22 0000 -------
This is a relatively recently introduced issue related to IEEE floating point
operations going on in the code that haven't yet been isolated.  I believe that
if you add -mieee or a similar IEEE compliance option that you can then proceed
to use any -O# optimization level desired.

one of the bzflag devs

------- Comment #4 From Christopher Sean Morrison 2006-10-27 13:54:02 0000 -------
It's also probably worth mentioning that there was a separate issue in the
networking protocol that affected (only some) 64-bit platforms that caused
similar inabilities to shoot other players that has been fixed in the latest
CVS sources but not yet pushed out via a public release.

The next public release isn't scheduled until around the end of the calendar
year.  If, however, someone (tm) can work with the user experiencing this
problem to determine if it's the ieee or 64-bit issue and it's issue that folks
would like to see fixed earlier rather than later, then a patch could probably
be put together.  Otherwise, both of the issues should be fixed for the next
release.

Cheers!
Sean

------- Comment #5 From SpanKY 2006-10-27 22:46:09 0000 -------
i doubt it considering -mieee is an alpha/superh specific flag

the original comment is most likely correct ... bzflag uses casting that
violates ISO spec for aliasing and now that gcc-4 enables strict-aliasing by
default with -O2, people are noticing

------- Comment #6 From Tupone Alfredo 2006-12-22 14:21:12 0000 -------
A fix is now in portage. Thanks for report