Community
Participate
Working Groups
Build Identifier: Eclipse I20110613-1736 CDT 8.0 See steps to reproduce below... (The code compiles and works fine under VC++ compiler) Reproducible: Always Steps to Reproduce: Writing the following code causes "foo" to be unresolved: class A { int a; }; int foo(A &p) { return 0; } A get() { return A(); } int main() { foo(get()); // <- "foo" not resolved return 0; }
Hmmm, it doesn't compile with gcc 4.5.2 ang clang 2.9 though. error: invalid initialization of non-const reference of type 'A&' from an rvalue of type 'A' error: in passing argument 1 of 'int foo(A&)' If you use /Za (disable language extensions) in VS you should get Error 2 error C2664: 'foo' : cannot convert parameter 1 from 'A' to 'A &'
This is invalid c++ code. Microsoft decided not to support this feature in the future, see http://msdn.microsoft.com/en-us/library/s5b150wd(v=vs.71).aspx