Why and how does GCC compile a function with a missing return statement?

后端 未结 8 1030
萌比男神i
萌比男神i 2020-12-01 23:57
#include 

char toUpper(char);

int main(void)
{
    char ch, ch2;
    printf(\"lowercase input : \");
    ch = getchar();
    ch2 = toUpper(ch);
             


        
8条回答
  •  死守一世寂寞
    2020-12-02 00:48

    It depends on the Application Binary Interface and which registers are used for the computation.

    E.g. on x86, the first function parameter and the return value is stored in EAX and so gcc is most likely using this to store the result of the calculation as well.

提交回复
热议问题