Fixed issue from track Ticket #11209: conversion - cast_test leaks memory

This commit is contained in:
Antony Polukhin
2015-09-25 19:58:48 +03:00
parent a6100358f4
commit 8f4b6ec985

View File

@@ -51,7 +51,8 @@ int main( int argc, char * argv[] )
// test polymorphic_cast ---------------------------------------------------// // test polymorphic_cast ---------------------------------------------------//
// tests which should succeed // tests which should succeed
Base * base = new Derived; Derived derived_instance;
Base * base = &derived_instance;
Base2 * base2 = 0; Base2 * base2 = 0;
Derived * derived = 0; Derived * derived = 0;
derived = polymorphic_downcast<Derived*>( base ); // downcast derived = polymorphic_downcast<Derived*>( base ); // downcast
@@ -66,7 +67,8 @@ int main( int argc, char * argv[] )
// tests which should result in errors being detected // tests which should result in errors being detected
int err_count = 0; int err_count = 0;
base = new Base; Base base_instance;
base = &base_instance;
if ( argc > 1 && *argv[1] == '1' ) if ( argc > 1 && *argv[1] == '1' )
{ derived = polymorphic_downcast<Derived*>( base ); } // #1 assert failure { derived = polymorphic_downcast<Derived*>( base ); } // #1 assert failure