Is there any compiler option that allows you to get a warning when you try to assign to temporary object?
Example:
struct S {
S op() { return S(); }
};
int main() {
S s;
s.op() = s; // assign to temporary. Wants to warn here.
}
I know that you can declare the return type of op
as const
to prevent such a situation, but now I'm interested in is the compiler options only.
You can use any popular modern compiler.