User forums > Using Code::Blocks
CB options
(1/1)
Turist:
Hello. I try to catch bad_alloc error (if "new" cannot allocate some memory) but program always shut down with "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information".
With other IDE everything ok.
Can you tell me, what flag or something else i need to use for stable processing "bad_alloc" without shot down program.
--- Code: ---#include <cstdlib>
#include <iostream>
#include <new>
using namespace std;
struct T
{
float Mas[0xFFFFFF];
};
void OutMem()
{
cout<<"MemOut\n";
throw(bad_alloc());
}
int main(int argc, char *argv[])
{
set_new_handler(OutMem);
try
{
T *Arr = new T[0xFFFFFF];
}
catch(bad_alloc& e)
{
cout<<"ERROR\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}
--- End code ---
PS. sorry for my english
PPS windows7 x64
oBFusCATed:
1. Start by reading the rules of the forum
2 continue with reading and executing you code by hand (line by line)
3. if you then don't know what is going on read a book about c++.
p.s. because of 1 your topic will be locked...
Turist:
I have read the rules. My question is not related to the code or compiler. Any project, return string as if i use abort(). Flags for my compiler is default as in other IDE , but return values is different. I think this happend by unknown for me, CB behavior. My deep apologise if i mistake.
stahta01:
--- Quote from: Turist on June 29, 2013, 05:40:23 pm ---I have read the rules. My question is not related to the code or compiler. Any project, return string as if i use abort(). Flags for my compiler is default as in other IDE , but return values is different. I think this happend by unknown for me, CB behavior. My deep apologise if i mistake.
--- End quote ---
Read at least some of the FAQs; before you post another post that does NOT belong on this site.
http://wiki.codeblocks.org/index.php?title=FAQ
Navigation
[0] Message Index
Go to full version