xkbcommon / libxkbcommon

keymap handling library for toolkits and window systems
https://xkbcommon.org
Other
278 stars 124 forks source link

compiling with gcc-12 generates lots of -Warray-bounds warnings in ast-build.c #292

Open stefson opened 2 years ago

stefson commented 2 years ago

hey everyone,

I just compiled libxkbcommon package for gentoo, and got all these warnings about possible runtime failures etc., and thought it was helpfull if I left you a note about them:

 * QA Notice: Package triggers severe warnings which indicate that it
 *            may exhibit random runtime failures.
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:81:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:91:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:110:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:120:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:130:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:141:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:156:13: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:153:13: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:157:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:158:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:169:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:170:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:180:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:181:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:182:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:192:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:193:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:203:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:81:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:91:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[24]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:110:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:120:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:130:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:141:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:156:13: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:153:13: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:157:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:158:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:169:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:170:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:180:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:181:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:182:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:192:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:193:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[40]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:203:9: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:130:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:67:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:68:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:69:19: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:70:27: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]
 * ../libxkbcommon-1.4.1/src/xkbcomp/ast-build.c:110:23: warning: array subscript ‘ExprDef[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds]

if these are false positives please let me know and I'll open a gcc bug instead

bluetech commented 2 years ago

I am building using gcc 12.2.0, and I'm not seeing these warnings. They also don't make much sense since there isn't any array access at these locations. Also not sure where the 32 is coming from.

I'm closing the issue, but we can reopen if someone can figure out what it's about.

bluetech commented 1 year ago

This shows up only when optimizations (inlining) are enabled. The issue is in how we model our AST. The relevant structs are:

// src/xkbcomp/ast.h

typedef struct _ParseCommon  {
    struct _ParseCommon *next;
    enum stmt_type type;
} ParseCommon;

typedef struct {
    ParseCommon common;
    enum expr_op_type op;
    enum expr_value_type value_type;
} ExprCommon;

typedef struct {
    ExprCommon expr;
    xkb_atom_t str;
} ExprString;

union ExprDef {
    ParseCommon common;
    ExprCommon expr;
    ExprIdent ident;
    ExprString string;
    ExprBoolean boolean;
    ExprInteger integer;
    ExprKeyName key_name;
    ExprBinary binary;
    ExprUnary unary;
    ExprFieldRef field_ref;
    ExprArrayRef array_ref;
    ExprAction action;
    ExprActionList actions;
    ExprKeysymList keysym_list;
};

The errors then come from this code (for example):

// src/xkbcomp/ast-build.c

static ExprDef *
ExprCreate(enum expr_op_type op, enum expr_value_type type, size_t size)
{
    ExprDef *expr = malloc(size);
    if (!expr)
        return NULL;

    expr->common.type = STMT_EXPR;
    expr->common.next = NULL;
    expr->expr.op = op;
    expr->expr.value_type = type;

    return expr;
}

ExprDef *
ExprCreateString(xkb_atom_t str)
{
    ExprDef *expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_STRING, sizeof(ExprString));
    if (!expr)
        return NULL;
    expr->string.str = str;
    return expr;
}

The problem is we allocate an ExprDef, whose size it that of the largest union member, let's say 72 bytes, using a sizeof(ExprString) malloc, which is 32 bytes. Of course, we never access beyond the 32 bytes, but probably just doing the above is undefined behavior of some sort, so gcc complains.

I think we can definitely do the AST more safely (and more efficiently!). Patches welcome.