[Bug c/66625] New: xorg-server (Ext/Xinerama) fails to build with -O3 optimizations

peter.ganzhorn at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 22 13:27:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66625

            Bug ID: 66625
           Summary: xorg-server (Ext/Xinerama) fails to build with -O3
                    optimizations
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: peter.ganzhorn at gmail dot com
  Target Milestone: ---

GCC 5.1.0 fails to build xorg-server with the -O3 option with the following
output:

xvdisp.c: In function ‘XineramifyXv’:
xvdisp.c:1783:37: error: array subscript is above array bounds
[-Werror=array-bounds]
                 if (MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
                                     ^
xvdisp.c:1784:31: error: array subscript is above array bounds
[-Werror=array-bounds]
                     port->info[k].id = MatchingAdaptors[k]->base_id + j;
                               ^
xvdisp.c:1786:31: error: array subscript is above array bounds
[-Werror=array-bounds]
                     port->info[k].id = 0;
                               ^
cc1: some warnings being treated as errors
Makefile:777: recipe for target 'xvdisp.lo' failed


This does *NOT* happen with gcc-4.9.

The xorg guys think this has to be a gcc bug.
Here is the bug report on their bug tracker:
Bug #91031 https://bugs.freedesktop.org/show_bug.cgi?id=91031

See their bug report for a more detailed explaination why they blame gcc and
not their code.


I'm running/building with
- Distro: Arch Linux (rolling-release, up-to-date)
- gcc-5.1 is from the official Arch Linux repo.
- Intel x64_64 (Haswell) with -march=native and -mtune=native

I have the following build options set via /etc/makepkg.conf (which is used for
package compilation from source on Arch Linux):
CARCH="x86_64"
CHOST="x86_64-unknown-linux-gnu"
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=native -mtune=native -O3 -pipe -fstack-protector-strong
--param=ssp-buffer-size=4"
CXXFLAGS="-march=native -mtune=native -O3 -pipe -fstack-protector-strong
--param=ssp-buffer-size=4"
LDFLAGS="-Wl,-O2,--sort-common,--as-needed,-z,relro"
MAKEFLAGS="-j16"
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"

Changing -O3 to -O2 makes the build complete without fatal errors and results
in a working xorg-server.


More information about the Gcc-bugs mailing list