What happens to unused function return values?

后端 未结 7 1590
太阳男子
太阳男子 2020-12-10 16:48

If I have a program:

#include 

using namespace std;

int TestIntReturn(int &x, int &y)
{
    x = 1000;
    y = 1000;
    return x+y;         


        
7条回答
  •  时光说笑
    2020-12-10 17:12

    Nothing - it goes into the ether, and is not stored/used. The return value itself is an rvalue or temporary; I believe the compiler will optimize even the temporary creation out due to it not actually being used.

提交回复
热议问题