You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In clang (and also others C++ compilers) the main function is linked against the CRT definition:
intmain(int argc, char *argv[])
which is a number of arguments and array of strings, that are arguments themselves parsed by space.
Linking process happens consequently and involves one-by-one check of ABI compatility. In our case, we expect the integer variable in both function signatures, which is fine, but missing second array of strings, which is also fine, surprisingly.
That way, the variable x in the program is linked against argc. This can be demonstrated here:
P. S. Note that first argument is always name of executable, a.exe in my case.
Yeah, but the problem of static typing does not allow us to do that. CMD Arguments are always captured as string, so we would need to embed string to int conversion code into out program, which is something I don't think we have right now. Also, for unified conversion we would need to embed all these other functions such as str to float, str to bool into CPlus.
Code to reproduce
Expected output
Prints 5
Actual output
Prints other random value, although the generated
ir.ll
seems correct.The text was updated successfully, but these errors were encountered: