Method stack return usage has incorrect GCC error

Jonathan Wakely jwakely.gcc@gmail.com
Fri Jul 6 17:28:00 GMT 2012


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.



More information about the Gcc-help mailing list