diff --git a/C++/malloc_error.cpp b/C++/malloc_error.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1eb3532ea88d6afa9f66a08a27d125262be713c1 --- /dev/null +++ b/C++/malloc_error.cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; + +struct A { + vector v; +}; + +int main() { + // Init the struct with 'malloc' which has a vector + A* a = reinterpret_cast(malloc(sizeof(A))); + // unexpected action + a->v.push_back(100); + return 0; +} \ No newline at end of file