# include
# include
# include
# include
int main ()
{
char * buffer;
buffer = malloc (2);
You've written past the end of the buffer you allocated. The result is undefined behavior. Some run time libraries with the right options have at least some ability to diagnose problems like this, but not all do, and even those that do only do so at run-time, and usually only when compiled with the correct options.