diff --git a/sourcehook/test/testhookmangen.cpp b/sourcehook/test/testhookmangen.cpp index 7bbbb0c..858f526 100644 --- a/sourcehook/test/testhookmangen.cpp +++ b/sourcehook/test/testhookmangen.cpp @@ -133,7 +133,7 @@ namespace } \ template <> struct MakeRet< PodRet##size > \ { \ - static PodRet##size Do(int a) NO_OPTIMIZE \ + static PodRet##size Do(int a) \ { \ PodRet##size x; \ memset(reinterpret_cast(x.actPod.x), a, size); \ @@ -157,9 +157,10 @@ namespace { \ static ObjRet##size Do(int a) NO_OPTIMIZE \ { \ - ObjRet##size x; \ - memset(reinterpret_cast(x.actObj.x), a, size); \ - return x; \ + ObjRet##size *x = new ObjRet##size; /* ptr: otherwise gcc optimizes away the temp obj */ \ + CAutoPtrDestruction< ObjRet##size > apd(x); \ + memset(reinterpret_cast(x->actObj.x), a, size); \ + return *x; \ } \ };