I think there is a confusion with the term I used 'compiler'.
I meant to say that the total process of compilation & linking at once. (Ex: cc -o test test.c)
Well, then lets talk in real terms of 2 stage building compiling & linking..
Still if I make my own malloc and call it in my program without prototyping
and in the end if I link it with the libc malloc.. that should work and malloc code will be generated. but the problem is that our call stack is not the way we wanted and the system dosent know that. It continues to execute the instructions until it violates some system's rules, so the error is undefined as it depends on the stack of that program.
i.e: if I use my custom void* malloc(int,int)
and I link it with std malloc
the compiler generates the code for malloc in the ASM level handling what to copy where.. etc..
but the problem is that malloc only used only one argument that we provided.
the next stack entry is still there and that will mess up the remaining of the stack..
so the next stack frame interprets it wrong again and do its own job untill it does something illegal as per the systems rules..
correct me if I am wrong..