This will not always lead to error. Some processor tolerates unaligned acces to memory. And in some case, the compiler will add extra instruction for the memory to be accesed in a proper way (but i don't think it's the case in your example). I did my own code to test on my own computer and there's no errror while executing. I thought the one you showed wasn't really good (not even freeing memory)
Code:
#include <stdlib.h>
#include <stdio.h>
int main()
{
void *ptr;
int i;
ptr = malloc(2 * sizeof(int) - 1);
if (malloc != NULL)
{
for (i = 0; i < sizeof(int); i++)
{
* (int *) ((int) ptr + i);
}
free(ptr);
printf("Looks like no memory alignement error happened\n");
}
else
{
printf("Error while allocating memory\n");
}
getchar();
return 0;
}