Turn up compiler warnings to level 4. I suspect you will get a warning, since this is a Microsoft extension (accepting a non-const reference to a temporary).
I can also do this with no warnings:
Code:class X { int n; public: X() {} void set_n(int nn) {n = nn;} }; X f1() {X x; return x;} void f2(X& x) {X& y = x; y.set_n(5);} int main() { f2(f1()); }