/** 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 */