6 Jul 2012 19:21
Method stack return usage has incorrect GCC error
Arthur Schwarz <aschwarz1309 <at> att.net>
2012-07-06 17:21:54 GMT
2012-07-06 17:21:54 GMT
IDE Netbeans 7.2RC1 GCC 4.5.3 compiled under Cygwin
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.
The code contains several examples of usage for function arguments. When a
stacked object, derived b1(++y);"" and ' derived b3 = b1.fnc1();'", is used
as an argument to a function, b1.fnc4(b3);"" and " b1.fnc4(b1);", no error is
generated. The diagnostic only occurs when the return argument fro a function is
used as an argument to another function.
Not that this is of the slightest concern to GCC (nor should it be), MSVC++ 2010
does not produce a diagnostis.
thanks
art
# include <cstdlib>
# include <iostream>
# include <iomanip>
using namespace std;
static int y = 0;
class base {
(Continue reading)
RSS Feed