-Werror=array-bounds with -flto
Using LTO one can see:
[ 370s] events.c: In function 'XineramaConfineCursorToWindow':
[ 370s] events.c:609:13: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations]
[ 370s] events.c:609:11: note: within this loop
[ 370s] events.c:605:49: error: array subscript -1 is below array bounds of 'struct _Window *[16]' [-Werror=array-bounds]
[ 370s] events.c:606:31: error: array subscript -1 is below array bounds of 'struct _Screen *[16]' [-Werror=array-bounds]
[ 370s] events.c:610:39: error: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Werror=array-bounds]
[ 370s] events.c:617:38: error: array subscript -2 is below array bounds of 'struct _Window *[16]' [-Werror=array-bounds]
[ 370s] events.c:619:35: error: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Werror=array-bounds]
It's maybe a false positive and one can fix that with:
--- /tmp/events.c.old 2019-03-27 10:55:21.101388832 +0100
+++ /tmp/events.c 2019-03-27 10:55:15.073264135 +0100
@@ -601,6 +601,7 @@
return;
i = PanoramiXNumScreens - 1;
+ assert (i >= 0);
RegionCopy(&pSprite->Reg1, &pSprite->windows[i]->borderSize);
off_x = screenInfo.screens[i]->x;