NULL_TREE as RETURN_EXPR, but the "return" statement has an argument ...

Richard Henderson rth@redhat.com
Sat Oct 11 03:17:00 GMT 2003


See check_return_expr:

  /* The fabled Named Return Value optimization, as per [class.copy]/15:

     [...]      For  a function with a class return type, if the expression
     in the return statement is the name of a local  object,  and  the  cv-
     unqualified  type  of  the  local  object  is the same as the function
     return type, an implementation is permitted to omit creating the  tem-
     porary  object  to  hold  the function return value [...]

     So, if this is a value-returning function that always returns the same
     local variable, remember it.

     It might be nice to be more flexible, and choose the first suitable
     variable even if the function sometimes returns something else, but
     then we run the risk of clobbering the variable we chose if the other
     returned expression uses the chosen variable somehow.  And people expect
     this restriction, anyway.  (jason 2000-11-19)

     See finish_function, genrtl_start_function, and declare_return_variable
     for other pieces of this optimization.  */


r~



More information about the Gcc mailing list