Bug 91031 - Build failure w/ gcc-5.1 and -O3 optimization level
Summary: Build failure w/ gcc-5.1 and -O3 optimization level
Status: RESOLVED MOVED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/Ext/Xinerama (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: low minor
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-19 15:13 UTC by peter.ganzhorn
Modified: 2018-12-13 18:34 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description peter.ganzhorn 2015-06-19 15:13:01 UTC
When building xorg-server 1.17.1 or 1.17.2 on Arch Linux (up-to-date, rolling release) with gcc 5.1 the build fails with:

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


The build completes successfully with gcc-5.1 and -O2 optimization level.
With gcc-4.9 and -O3 this did *not* happen.
Comment 1 Alan Coopersmith 2015-06-20 02:07:43 UTC
In XineramifyXv, MatchingAdaptors is defined as:
    XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
and port is defined as a PanoramiXRes, which in panoramiX.h has a member:
    PanoramiXInfo info[MAXSCREENS];


The lines in question are all in a loop written as:
            FOR_NSCREENS(k) { ... }

which is a macro defined in panoramiX.h as:
#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j)
#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++)

So the k loop can go from 0 to PanoramiXNumScreens, and the complaint
is that gcc somehow thinks PanoramiXNumScreens may be larger than MAXSCREENS.

In PanoramiXExtensionInit, it is initialized as:
    PanoramiXNumScreens = screenInfo.numScreens;
and I see no other settings of it anywhere in the X server (other than
the initialization to 0 in the non-Xinerama case).

screenInfo.numScreens is set to 0 in dix/main.c, and the code in AddScreens
to increment it won't increment past MAXSCREENS.

Unless someone else can see an explanation for this warning, I think gcc is
wrong here.
Comment 2 Pierre Ossman 2015-06-22 11:03:38 UTC
Seems reasonable. Can you make a report with the gcc folks?
Comment 3 peter.ganzhorn 2015-06-22 13:15:31 UTC
I'm going to file a bug report on the gcc bugtracker and post the link to it here.
Comment 4 peter.ganzhorn 2015-06-22 13:33:20 UTC
I filed a bug report at the gcc bug tracker:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66625

I also provided the link to this bug report in the one at the gcc bug tracker so they have access to Alan Coopersmith's code analysis and conclusion that this most likely is a gcc issue.
Comment 5 GitLab Migration User 2018-12-13 18:34:06 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/239.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.