Demonstrates crash on memory allocation.
main.cpp
- Committer:
- Kemp
- Date:
- 2011-03-29
- Revision:
- 0:786b75c6aaca
- Child:
- 1:883b8bc1f54a
File content as of revision 0:786b75c6aaca:
#include "mbed.h"
Serial pc(USBTX, USBRX);
extern "C" void HardFault_Handler()
{
pc.printf("Hard fault!\r\n");
exit(1);
}
void fail()
{
pc.printf("Caught the failure\r\n");
exit(1);
}
class Test
{
public:
int something;
char woot[28];
};
int main() {
Test *dummy;
int index = 0;
while(1) {
dummy = new Test;
if (dummy == NULL) fail();
pc.printf("%u\r\n", index);
++index;
}
}