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.
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.
Seems reasonable. Can you make a report with the gcc folks?
I'm going to file a bug report on the gcc bugtracker and post the link to it here.
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.
-- 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.