O
Old Admiral
Gentlemen:
Is this UB?
#include <iostream>
const int& f()
{
return 3;
}
int main()
{
const int& s = f();
std::cout << s << '\n';
}
My compiler does warn me about it, but what I would like to know is
this:
Wouldn't the "const int&" part bind to the temporary like in the case
of:
const int& i = 3;
?
Thanks for your help.
Old Admiral salutes you.
OA.
Is this UB?
#include <iostream>
const int& f()
{
return 3;
}
int main()
{
const int& s = f();
std::cout << s << '\n';
}
My compiler does warn me about it, but what I would like to know is
this:
Wouldn't the "const int&" part bind to the temporary like in the case
of:
const int& i = 3;
?
Thanks for your help.
Old Admiral salutes you.
OA.