changeset 578:87b5f5d7af1f

callback_plain_c++: improved cross-platform robustness of faked thiscall used for testing
author Tassilo Philipp
date Thu, 08 Sep 2022 16:15:52 +0200
parents 864cf3c3ceb9
children 1d4f0f516483
files test/callback_plain_c++/test_main.cc
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/callback_plain_c++/test_main.cc	Thu Sep 08 15:31:44 2022 +0200
+++ b/test/callback_plain_c++/test_main.cc	Thu Sep 08 16:15:52 2022 +0200
@@ -130,7 +130,7 @@
   int ret = 1;
 
   const char *sigs[] = {
-    ")A",   // standard call
+    ")A",    // standard call
     "_*p)A"  // thiscall w/ this-ptr arg (special retval register handling in win/x64 calling conv)
   };
 
@@ -142,8 +142,9 @@
     DCaggr *aggrs[1] = { NULL }; // one non-triv aggr
     DCCallback* cb = dcbNewCallback2(sigs[i], &cbNonTrivAggrReturnHandler, sigs+i, aggrs);
 
-    DCpointer fakeClass[sizeof(Dummy)/sizeof(sizeof(DCpointer))];
-    fakeClass[0] = &cb; // write method ptr f
+    DCpointer fakeClass[sizeof(Dummy)/sizeof(DCpointer)];
+    for(int j=0; j<sizeof(Dummy)/sizeof(DCpointer); ++j)
+    	fakeClass[j] = &cb; // hack: write method ptr f over entire vtable to be sure
 
     // potential copy elision on construction
     NonTriv result = is_method ? ((Dummy*)&fakeClass)->f() : ((NonTriv(*)())cb)();