-- v2: msvcrt: Construct a real C++ object to test against. msvcr90: Fix warning on object access tests.
From: Eric Pouech eric.pouech@gmail.com
GCC 12 complains about accessing a too small object.
In function 'test__AdjustPointer', inlined from 'func_msvcr90' at wine/dlls/msvcr90/tests/msvcr90.c:2515:5: wine/dlls/msvcr90/tests/msvcr90.c:1556:30: warning: array subscript 30 is outside array bounds of 'void[8]' [-Warray-bounds] 1556 | {&obj1, (char*)&obj1 + obj.off, {0, 0, 0}}, | ~~~~~~~~~~~~~^~~~~~~~~
Since we're only checking the addresses and not the underlying objects, use uintptr_t instead of pointers.
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/msvcr90/tests/msvcr90.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c index 0d28df217ab..cdc9de0d6d2 100644 --- a/dlls/msvcr90/tests/msvcr90.c +++ b/dlls/msvcr90/tests/msvcr90.c @@ -1542,28 +1542,28 @@ static void test__AdjustPointer(void) void *obj1 = &obj.off; void *obj2 = &obj; struct test_data { - void *ptr; - void *ret; + uintptr_t ptr; + uintptr_t ret; struct { int this_offset; int vbase_descr; int vbase_offset; } this_ptr_offsets; } data[] = { - {NULL, NULL, {0, -1, 0}}, - {(void*)0xbeef, (void*)0xbef0, {1, -1, 1}}, - {(void*)0xbeef, (void*)0xbeee, {-1, -1, 0}}, - {&obj1, (char*)&obj1 + obj.off, {0, 0, 0}}, - {(char*)&obj1 - 5, (char*)&obj1 + obj.off, {0, 5, 0}}, - {(char*)&obj1 - 3, (char*)&obj1 + obj.off + 24, {24, 3, 0}}, - {(char*)&obj2 - 17, (char*)&obj2 + obj.off + 4, {4, 17, sizeof(int)}} + {0, 0, {0, -1, 0}}, + {0xbeef, 0xbef0, {1, -1, 1}}, + {0xbeef, 0xbeee, {-1, -1, 0}}, + {(uintptr_t)&obj1, (uintptr_t)&obj1 + obj.off, {0, 0, 0}}, + {(uintptr_t)&obj1 - 5, (uintptr_t)&obj1 + obj.off, {0, 5, 0}}, + {(uintptr_t)&obj1 - 3, (uintptr_t)&obj1 + obj.off + 24, {24, 3, 0}}, + {(uintptr_t)&obj2 - 17, (uintptr_t)&obj2 + obj.off + 4, {4, 17, sizeof(int)}} }; void *ret; int i;
for(i=0; i<ARRAY_SIZE(data); i++) { - ret = p__AdjustPointer(data[i].ptr, &data[i].this_ptr_offsets); - ok(ret == data[i].ret, "%d) __AdjustPointer returned %p, expected %p\n", i, ret, data[i].ret); + ret = p__AdjustPointer((void*)data[i].ptr, &data[i].this_ptr_offsets); + ok(ret == (void*)data[i].ret, "%d) __AdjustPointer returned %p, expected %p\n", i, ret, (void*)data[i].ret); } }
From: Piotr Caban eric.pouech@codeweavers.com
This fixes GCC12 warnings about accessing a too small object.
wine/dlls/msvcrt/tests/cpp.c: In function 'test_rtti': wine/dlls/msvcrt/tests/cpp.c:1036:45: warning: array subscript 2 is outside array bounds of 'void[4]' [-Warray-bounds] 1036 | ok (casted == (char*)&child_class_sig0+8, "failed cast to simple_class (%p %p)\n", casted, &child_class_sig0); | ~~~~~~~~~~~~~~~~~~~~~~~~^~
Signed-off-by: Piotr Caban piotr.caban@codeweavers.com Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/msvcrt/tests/cpp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c index b2b6a1909b7..e5fa652ede2 100644 --- a/dlls/msvcrt/tests/cpp.c +++ b/dlls/msvcrt/tests/cpp.c @@ -943,11 +943,17 @@ static void test_rtti(void) void *simple_class_vtbl[2] = {&simple_class_rtti.object_locator}; void *simple_class = &simple_class_vtbl[1]; void *child_class_vtbl[2] = {&child_class_rtti.object_locator}; - void *child_class = &child_class_vtbl[1]; + struct { + void *vtbl; + char data[4]; + } child_class = { &child_class_vtbl[1] }; void *simple_class_sig0_vtbl[2] = {&simple_class_sig0_rtti.object_locator}; void *simple_class_sig0 = &simple_class_sig0_vtbl[1]; void *child_class_sig0_vtbl[2] = {&child_class_sig0_rtti.object_locator}; - void *child_class_sig0 = &child_class_sig0_vtbl[1]; + struct { + void *vtbl; + char data[4]; + } child_class_sig0 = { &child_class_sig0_vtbl[1] }; void *virtual_base_class_vtbl[2] = {&virtual_base_class_rtti.object_locator}; int virtual_base_class_vbtbl[2] = {0, 0x100}; struct {
V2 pushed: - replaced second patch with Piotr's solution
This merge request was approved by Piotr Caban.