https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92867

Ulrich Drepper <drepper.fsp+rhbz at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drepper.fsp+rhbz at gmail dot 
com

--- Comment #4 from Ulrich Drepper <drepper.fsp+rhbz at gmail dot com> ---
This BZ came out of a discussion around C++ function call chaining along the
line of:

void f1(std::string& s, int a)
{
  std::cout << "hello " << s;
  if (a != 0)
    std::cout << a;
  std::cout << '\n';
}

The 'if' prevents one single series of calls through operator<< from being used
and the compiler has reload std::cout from memory every time.  There are ugly
work-arounds in the source to get the desired behaviour but this should happen
automatically.  The work-arounds are too ugly and there is lots of code out
there.

One way would be to expose a way to specify one of the arguments is returned. 
Jakub mentioned that there is already internally a way to use the "fn spec"
attribute.  How about exposing this explicitly as a function attribute?

Jakub also raised the point how this should be applied to member functions.  I
suggest that the parameter for the attribute is really a number (not parameter
name) and that argument 1 (or 0, if you want the count start at zero) refers to
'this' in case of member functions.

How about this?

Reply via email to