I wrote a basic "Hello World" program in C:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
Then, I compiled it in MSVC from the command-line as such:
cl hello.c /Fd:hello.pdb /Zi /MD /link /NODEFAULTLIB:LIBCMT.LIB
The command line arguments basically say "generate a PDB file and link with MSVCRT.LIB rather than LIBCMT.LIB".
Then, I disassembled the program and looked at the various boilerplate/CRT functions and found this in the disassembly, which was curious:
__matherr:
00401550: 33 C0 xor eax,eax
00401552: C3 ret
This is basically a function that always returns 0 in EAX whenever it's called. According to the documentation of this function, it returns 0 when there is a math error and non-0 when there isn't an error.
Does anyone have an answer as to why this function, which is supposed to return 0 in the case of a math error, is included in the executable and is hard-coded to always return 0?