From 3dfa82a5c3a3a44e9a5b61e38f26a3af5e475800 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Tue, 17 Nov 2015 22:34:33 -0700 Subject: [PATCH] Fixed STUB_RETREF() implementation to return the right type. Removed bogus STUB_RETREF() comment about memory leaks in _unreachable_ code. Deprecated STUB_RETSTATREF() as essentially duplicating STUB_RETREF(). --- src/tests/STUB.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/tests/STUB.h b/src/tests/STUB.h index 4660bf0182..406266c40a 100644 --- a/src/tests/STUB.h +++ b/src/tests/STUB.h @@ -46,17 +46,12 @@ /** macro to stub a function which returns a reference to dynamic * Aborts unit tests requiring its definition with a message about the missing linkage - * This macro uses 'new x' to construct a stack vailable for the reference, may leak. - * \param x may be the type to define or a constructor call with parameter values + * \param x underlying or "referred to" type */ -#define STUB_RETREF(x) { stub_fatal(STUB_API " required"); return new x; } +#define STUB_RETREF(x) { stub_fatal(STUB_API " required"); return *(x *)nullptr; } -/** macro to stub a function which returns a reference to static - * Aborts unit tests requiring its definition with a message about the missing linkage - * This macro uses static variable definition to avoid leaks. - * \param x the type name to define - */ -#define STUB_RETSTATREF(x) { stub_fatal(STUB_API " required"); static x v; return v; } +/** Same as STUB_RETREF(). TODO: Remove */ +#define STUB_RETSTATREF(x) STUB_RETREF(x) #endif /* STUB */ -- 2.47.2