Mark args local variable with volatile to tell GCC not to check for out of bounds access.
Alternative fix: use an intermediate variable to store &fun as an integer.
MingW/GCC 12 complains with:
In file included from /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:36: /home/eric/work/wine/dlls/krnl386.exe16/thunk.c: In function 'SSCall': /home/eric/work/wine/include/wine/debug.h:91:4: warning: array subscript 1 is outside array bounds of 'INT_PTR (__attribute__((stdcall)) *[1])(void)' {aka 'int (__attribute__((stdcall)) *[1])(void)'} [-Warray-bounds] 91 | wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:88:8: note: in expansion of macro '__WINE_DBG_LOG' 88 | __WINE_DBG_LOG | ^~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:463:36: note: in expansion of macro '__WINE_DPRINTF' 463 | #define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default) | ^~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:506:36: note: in expansion of macro 'WINE_TRACE' 506 | #define TRACE WINE_TRACE | ^~~~~~~~~~ /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:996:32: note: in expansion of macro 'TRACE' 996 | for (i = 0; i < nr/4; i++) TRACE("0x%08lx,",args[i]); | ^~~~~ /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:989:17: note: at offset 4 into object 'fun' of size 4 989 | FARPROC fun, /* [in] function to call */ | ~~~~~~~~^~~
Signed-off-by: Eric Pouech eric.pouech@gmail.com
From: Eric Pouech eric.pouech@gmail.com
Mark args local variable with volatile to tell GCC not to check for out of bounds access.
Alternative fix: use an intermediate variable to store &fun as an integer.
MingW/GCC 12 complains with:
In file included from /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:36: /home/eric/work/wine/dlls/krnl386.exe16/thunk.c: In function 'SSCall': /home/eric/work/wine/include/wine/debug.h:91:4: warning: array subscript 1 is outside array bounds of 'INT_PTR (__attribute__((stdcall)) *[1])(void)' {aka 'int (__attribute__((stdcall)) *[1])(void)'} [-Warray-bounds] 91 | wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:88:8: note: in expansion of macro '__WINE_DBG_LOG' 88 | __WINE_DBG_LOG | ^~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:463:36: note: in expansion of macro '__WINE_DPRINTF' 463 | #define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default) | ^~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:506:36: note: in expansion of macro 'WINE_TRACE' 506 | #define TRACE WINE_TRACE | ^~~~~~~~~~ /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:996:32: note: in expansion of macro 'TRACE' 996 | for (i = 0; i < nr/4; i++) TRACE("0x%08lx,",args[i]); | ^~~~~ /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:989:17: note: at offset 4 into object 'fun' of size 4 989 | FARPROC fun, /* [in] function to call */ | ~~~~~~~~^~~
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/krnl386.exe16/thunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/krnl386.exe16/thunk.c b/dlls/krnl386.exe16/thunk.c index 6b289eac65e..16452e441f6 100644 --- a/dlls/krnl386.exe16/thunk.c +++ b/dlls/krnl386.exe16/thunk.c @@ -990,7 +990,8 @@ DWORD WINAPIV SSCall( ... /* [in/out] arguments */ ) { DWORD i,ret; - DWORD *args = ((DWORD *)&fun) + 1; + /* volatile avoids GCC warning when accessing memory after the 4 bytes of 'fun' */ + DWORD * volatile args = ((DWORD *)&fun) + 1;
TRACE("(%ld,0x%08lx,%p,[",nr,flags,fun); for (i = 0; i < nr/4; i++) TRACE("0x%08lx,",args[i]);
On 12/10/22 07:28, Eric Pouech wrote:
From: Eric Pouech eric.pouech@gmail.com
Mark args local variable with volatile to tell GCC not to check for out of bounds access.
Alternative fix: use an intermediate variable to store &fun as an integer.
MingW/GCC 12 complains with:
In file included from /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:36: /home/eric/work/wine/dlls/krnl386.exe16/thunk.c: In function 'SSCall': /home/eric/work/wine/include/wine/debug.h:91:4: warning: array subscript 1 is outside array bounds of 'INT_PTR (__attribute__((stdcall)) *[1])(void)' {aka 'int (__attribute__((stdcall)) *[1])(void)'} [-Warray-bounds] 91 | wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:88:8: note: in expansion of macro '__WINE_DBG_LOG' 88 | __WINE_DBG_LOG | ^~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:463:36: note: in expansion of macro '__WINE_DPRINTF' 463 | #define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default) | ^~~~~~~~~~~~~~ /home/eric/work/wine/include/wine/debug.h:506:36: note: in expansion of macro 'WINE_TRACE' 506 | #define TRACE WINE_TRACE | ^~~~~~~~~~ /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:996:32: note: in expansion of macro 'TRACE' 996 | for (i = 0; i < nr/4; i++) TRACE("0x%08lx,",args[i]); | ^~~~~ /home/eric/work/wine/dlls/krnl386.exe16/thunk.c:989:17: note: at offset 4 into object 'fun' of size 4 989 | FARPROC fun, /* [in] function to call */ | ~~~~~~~~^~~
Signed-off-by: Eric Pouech eric.pouech@gmail.com
dlls/krnl386.exe16/thunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/krnl386.exe16/thunk.c b/dlls/krnl386.exe16/thunk.c index 6b289eac65e..16452e441f6 100644 --- a/dlls/krnl386.exe16/thunk.c +++ b/dlls/krnl386.exe16/thunk.c @@ -990,7 +990,8 @@ DWORD WINAPIV SSCall( ... /* [in/out] arguments */ ) { DWORD i,ret;
- DWORD *args = ((DWORD *)&fun) + 1;
/* volatile avoids GCC warning when accessing memory after the 4 bytes of 'fun' */
DWORD * volatile args = ((DWORD *)&fun) + 1;
TRACE("(%ld,0x%08lx,%p,[",nr,flags,fun); for (i = 0; i < nr/4; i++) TRACE("0x%08lx,",args[i]);
This seems pretty awful either way; I think we should be implementing this in assembly if we have to implement it at all. What do you think of the attached patch?
This merge request was closed by eric pouech.