このコードがCode::blockで正常に実行されるのはなぜですか。IDBはただ報告します
警告:「ローカル変数'tmp'への参照が返されました」、
しかし、結果「helloworld」を正常に出力します。
#include <iostream>
#include<string>
using namespace std;
const string &getString(const string &s)
{
string tmp = s;
return tmp;
}
int main()
{
string a;
cout<<getString("hello world")<<endl;
return 0;
}