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