-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
#include <cstdio>
#include <utility>
struct A { operator int&(); };
int& ir = A();
int main()
{
return 0;
}
This block of code will be transformed to
#include <cstdio>
#include <utility>
struct A
{
operator int & ();
};
int & ir = static_cast<int>(A().operator int &());
int main()
{
return 0;
}
which can not be compiled correctly, because the return value of static_cast<int> is a rvalue and c++ standard does not allowed that non-const lvalue reference of type'int' binds to a rvalue of type int.
According to the standard, it should use the conversion function turnsA() into a int& type.
Here is the link of this term in a html version of cpp working paper.
https://timsong-cpp.github.io/cppwp/n4868/dcl.init.ref#5.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working