Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stefson opened this issue Jun 25, 2022 · 2 comments
Labels
compiler warning Compiler emits warnings that should be avoided help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@stefson
Copy link

stefson commented Jun 25, 2022

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
Copy link
Member

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
Copy link
Member

bluetech commented May 6, 2023

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.

@bluetech bluetech reopened this May 6, 2023
@wismill wismill added help wanted Indicates that a maintainer wants help on an issue or pull request compiler warning Compiler emits warnings that should be avoided labels May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler warning Compiler emits warnings that should be avoided help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants