Mam nadzieję, że o coś takiego chodziło:
Metoda zawierająca menu główne. Miedzy innymi w niej przy usuwaniu obiektów tworzonych w pętli, dtor nie jest wywoływany.
void C_Main::run() {
do {
cout << "<---------------->" << endl;
cout << "Menu Glowne" << endl;
do {
if( main_choice > 4 ) {
cout << "<---------------->" << endl;
cout << "Bledny wybor!" << endl;
}
if( cin.fail() ) {
cout << "<---------------->" << endl;
cout << "Blad wczytywania danych!" << endl;
cin.clear();
cin.ignore( numeric_limits < streamsize >::max(), '\n' );
}
cout << "<---------------->" << endl;
cout << "0 - Zamknij program" << endl;
cout << "1 - Symulacja" << endl;
cout << "2 - Odczytywanie danych z analizy" << endl;
cout << "3 - Ustawienia" << endl;
cout << "4 - Obszar testowy" << endl;
cout << "Twoj wybor: ";
cin >> main_choice;
} while( cin.fail() || main_choice > 4 );
switch( main_choice ) {
case 0:
return;
case 1: {
running = new C_Universe( num_of_sim, path + L"/simulations" );
break;
}
case 2: {
running = new C_Analysis_Access;
break;
}
case 3: {
running = & global_settings;
break;
}
case 4: {
running = new C_Test;
break;
}
}
running->run();
if( main_choice == 2 ) {
continue;
}
delete running;
} while( true );
}
Wygenerowany asm (wraz z linijkami kodu w komentarzach):
_TEXT SEGMENT
$T18 = 48
$T6 = 64
$T11 = 176
this$ = 176
$T12 = 184
$T9 = 192
$T5 = 200
?run@C_Main@@QEAAXXZ PROC ; C_Main::run, COMDAT
; 14 : void C_Main::run() {
$LN110:
push rbx
push rbp
push rsi
push rdi
push r12
push r13
push r14
push r15
sub rsp, 104 ; 00000068H
mov QWORD PTR $T18[rsp], -2
mov rsi, rcx
mov r14, 9223372036854775807 ; 7fffffffffffffffH
lea r13, OFFSET FLAT:??_7C_Test@@6B@
mov r15, 4627167142146473984 ; 4037000000000000H
lea r12, OFFSET FLAT:??_7C_Base@@6B@
npad 1
$LL4@run:
; 15 : do {
; 16 : cout << "<---------------->" << endl;
lea rdx, OFFSET FLAT:??_C@_0BD@OJIDEFJN@?$DM?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?$DO?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 17 : cout << "Menu Glowne" << endl;
lea rdx, OFFSET FLAT:??_C@_0M@MONKOAFM@Menu?5Glowne?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
mov rdx, QWORD PTR __imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A
npad 3
$LL7@run:
; 18 : do {
; 19 : if (main_choice > 4) {
cmp DWORD PTR [rsi+352], 4
jbe SHORT $LN10@run
; 20 : cout << "<---------------->" << endl;
lea rdx, OFFSET FLAT:??_C@_0BD@OJIDEFJN@?$DM?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?$DO?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 21 : cout << "Bledny wybor!" << endl;
lea rdx, OFFSET FLAT:??_C@_0O@HOMBNDHB@Bledny?5wybor?$CB?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
mov rdx, QWORD PTR __imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A
$LN10@run:
; 23 : if (cin.fail()) {
mov rax, QWORD PTR [rdx]
movsxd rcx, DWORD PTR [rax+4]
; File c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xiosbase
; 348 : return (((int)rdstate()
test BYTE PTR [rcx+rdx+16], 6
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_main.cpp
; 23 : if (cin.fail()) {
je SHORT $LN11@run
; 24 : cout << "<---------------->" << endl;
lea rdx, OFFSET FLAT:??_C@_0BD@OJIDEFJN@?$DM?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?$DO?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 25 : cout << "Blad wczytywania danych!" << endl;
lea rdx, OFFSET FLAT:??_C@_0BJ@FOCJOIFK@Blad?5wczytywania?5danych?$CB?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 26 : cin.clear();
mov rdx, QWORD PTR __imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A
mov rax, QWORD PTR [rdx]
movsxd rcx, DWORD PTR [rax+4]
add rcx, rdx
xor r8d, r8d
xor edx, edx
call QWORD PTR __imp_?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z
; 27 : cin.ignore(numeric_limits<streamsize>::max(), '\n');
mov r8d, 10
mov rdx, r14
mov rcx, QWORD PTR __imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A
call QWORD PTR __imp_?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z
$LN11@run:
; 28 : }
; 29 : cout << "<---------------->" << endl;
lea rdx, OFFSET FLAT:??_C@_0BD@OJIDEFJN@?$DM?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9?$DO?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 30 : cout << "0 - Zamknij program" << endl;
lea rdx, OFFSET FLAT:??_C@_0BE@EKEBEBLO@0?5?9?5Zamknij?5program?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 31 : cout << "1 - Symulacja" << endl;
lea rdx, OFFSET FLAT:??_C@_0O@JLCNOCMM@1?5?9?5Symulacja?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 32 : cout << "2 - Odczytywanie danych z analizy" << endl;
lea rdx, OFFSET FLAT:??_C@_0CC@DDJBLOMN@2?5?9?5Odczytywanie?5danych?5z?5analiz@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 33 : cout << "3 - Ustawienia" << endl;
lea rdx, OFFSET FLAT:??_C@_0P@MGJHKAGJ@3?5?9?5Ustawienia?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 34 : cout << "4 - Obszar testowy" << endl;
lea rdx, OFFSET FLAT:??_C@_0BD@OINPKOPL@4?5?9?5Obszar?5testowy?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
mov rcx, rax
lea rdx, OFFSET FLAT:??$endl@DU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@@Z ; std::endl<char,std::char_traits<char> >
call QWORD PTR __imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
; 35 : cout << "Twoj wybor: ";
lea rdx, OFFSET FLAT:??_C@_0N@BCAHJHEK@Twoj?5wybor?3?5?$AA@
mov rcx, QWORD PTR __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
call ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z ; std::operator<<<std::char_traits<char> >
; 36 : cin >> main_choice;
lea rdx, QWORD PTR [rsi+352]
mov rcx, QWORD PTR __imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A
call QWORD PTR __imp_??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z
; 37 : } while (cin.fail() || main_choice > 4);
mov rdx, QWORD PTR __imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A
mov rax, QWORD PTR [rdx]
movsxd rcx, DWORD PTR [rax+4]
; File c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xiosbase
; 348 : return (((int)rdstate()
test BYTE PTR [rcx+rdx+16], 6
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_main.cpp
; 37 : } while (cin.fail() || main_choice > 4);
jne $LL7@run
mov eax, DWORD PTR [rsi+352]
cmp eax, 4
ja $LL7@run
; 38 : switch (main_choice) {
test eax, eax
je $LN3@run
sub eax, 1
je $LN13@run
sub eax, 1
je $LN14@run
sub eax, 1
je SHORT $LN15@run
cmp eax, 1
jne $LN8@run
; 54 : running = new C_Test;
lea ecx, QWORD PTR [rax+31]
call ??2@YAPEAX_K@Z ; operator new
mov rbx, rax
mov QWORD PTR $T11[rsp], rax
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_test.cpp
; 27 : C_Test::C_Test() {
mov QWORD PTR [rax], r13
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_test.h
; 30 : i[2] = {23, 23};
mov QWORD PTR [rax+16], r15
mov QWORD PTR [rax+24], r15
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_test.cpp
; 28 : obj = new MyClass[5];
mov ecx, 13
call ??_U@YAPEAX_K@Z ; operator new[]
mov QWORD PTR $T12[rsp], rax
test rax, rax
je SHORT $LN89@run
mov QWORD PTR [rax], 5
lea rbp, QWORD PTR [rax+8]
lea rax, OFFSET FLAT:??1MyClass@@QEAA@XZ ; MyClass::~MyClass
mov QWORD PTR [rsp+32], rax
lea r9, OFFSET FLAT:??0MyClass@@QEAA@XZ ; MyClass::MyClass
mov edx, 1
lea r8d, QWORD PTR [rdx+4]
mov rcx, rbp
call ??_L@YAXPEAX_K1P6AX0@Z2@Z
jmp SHORT $LN90@run
$LN89@run:
xor ebp, ebp
$LN90@run:
mov QWORD PTR [rbx+8], rbp
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_main.cpp
; 54 : running = new C_Test;
mov QWORD PTR [rsi+344], rbx
jmp SHORT $LN8@run
$LN15@run:
; 48 : }
; 49 : case 3: {
; 50 : running = &global_settings;
lea rax, QWORD PTR [rsi+360]
; 51 : break;
jmp SHORT $LN109@run
$LN14@run:
; 43 : break;
; 44 : }
; 45 : case 2: {
; 46 : running = new C_Analysis_Access;
mov ecx, 344 ; 00000158H
call ??2@YAPEAX_K@Z ; operator new
mov QWORD PTR $T9[rsp], rax
mov rcx, rax
call ??0C_Analysis_Access@@QEAA@XZ ; C_Analysis_Access::C_Analysis_Access
npad 1
; 47 : break;
jmp SHORT $LN109@run
$LN13@run:
; 39 : case 0:
; 40 : return;
; 41 : case 1: {
; 42 : running = new C_Universe(num_of_sim, path + L"/simulations");
mov ecx, 728 ; 000002d8H
call ??2@YAPEAX_K@Z ; operator new
mov rbx, rax
mov QWORD PTR $T5[rsp], rax
lea rdx, QWORD PTR [rsi+312]
lea r8, OFFSET FLAT:??_C@_1BK@DCJOPDIJ@?$AA?1?$AAs?$AAi?$AAm?$AAu?$AAl?$AAa?$AAt?$AAi?$AAo?$AAn?$AAs?$AA?$AA@
lea rcx, QWORD PTR $T6[rsp]
call ??$?H_WU?$char_traits@_W@std@@V?$allocator@_W@1@@std@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@AEBV10@QEB_W@Z ; std::operator+<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >
lea rdx, QWORD PTR [rsi+356]
mov r8, rax
mov rcx, rbx
call ??0C_Universe@@QEAA@AEAIV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z ; C_Universe::C_Universe
npad 1
$LN109@run:
mov QWORD PTR [rsi+344], rax
$LN8@run:
; 55 : break;
; 56 : }
; 57 : }
; 58 : running->run();
mov rcx, QWORD PTR [rsi+344]
mov rax, QWORD PTR [rcx]
call QWORD PTR [rax]
; 59 : if (main_choice == 2) {
cmp DWORD PTR [rsi+352], 2
je $LL4@run
; 60 : continue;
; 61 : }
; 62 : delete running;
mov rcx, QWORD PTR [rsi+344]
test rcx, rcx
je $LL4@run
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_base.cpp
; 10 : {
mov QWORD PTR [rcx], r12
mov edx, 8
call ??3@YAXPEAX_K@Z ; operator delete
; File c:\users\26kub\documents\visual studio 2017\projects\spacephysicssimulator\spacephysicssimulator\c_main.cpp
; 63 : } while (true);
jmp $LL4@run
$LN3@run:
; 64 : }
add rsp, 104 ; 00000068H
pop r15
pop r14
pop r13
pop r12
pop rdi
pop rsi
pop rbp
pop rbx
ret 0
?run@C_Main@@QEAAXXZ ENDP ; C_Main::run
_TEXT ENDS