On 6 July 2012 18:28, Jonathan Wakely wrote: > On 6 July 2012 18:21, Arthur Schwarz wrote: >> >> In the following example I think that gcc has incorrectly generated an "error: >> no matching function for call to ‘derived::fnc4(derived)’" error for " >> b1.fnc4(b1.fnc1());". My guess is that gcc does not handle a function return >> returning an object on the stack used as an argument to a function. If this is >> incorrect, on my part, would someone explain why I am wrong. > > Your function returns an rvalue which cannot bind to a non-const > lvalue-reference. > > i.e. an lvalue reference such as "derived&" cannot bind to a > temporary, such as the return value of your function. > >> Not that this is of the slightest concern to GCC (nor should it be), MSVC++ 2010 >> does not produce a diagnostis. > > This is a well-known bug^W feature of MSVC, I think there's some > switch to make it follow the standard and disable it. See e.g. http://stackoverflow.com/questions/3897702/why-does-msvc-let-me-do-this-but-not-gcc-g