Revisiting Issue C-18: Result buffers

Cary Coutant cary at cup.hp.com
Fri Apr 29 20:55:28 UTC 2005


I was recently asked about Section 3.1.4 (Return Values) in the C++ ABI 
spec, where it states:

"... if the return value type has a non-trivial copy constructor or 
destructor, the caller allocates space for a temporary, and passes a 
pointer to the temporary as an implicit first parameter preceding both 
the this parameter and user parameters. The callee constructs the 
return value into this temporary. On Itanium, the pointer is passed in 
out0, different from other large class result buffer pointers, passed 
in r8."

The HP compiler follows this convention, but g++ on HP-UX does not, 
causing a binary incompatibility between the two compilers.

I dug up Issue C-18, which purports to have changed this convention to 
use r8, just as the base C ABI would, and as g++ does:

> Summary: Should buffers for results with non-trivial copy constructors 
> be passed as a dummy first parameter, or in r8 as specified by the 
> psABI for long structured results?
>
> Resolution: All results with non-trivial copy constructors or 
> destructors will be returned in buffers allocated by the caller, with 
> their addresses passed as an implicit first parameter. Other structure 
> results too large for the return registers are returned in a buffer 
> created by the caller, with the buffer address passed in r8.
>
> ...
>
> [000817 All] Accepted. In all cases where a result class object is 
> returned in a buffer created by the caller, the buffer address will be 
> passed in r8, and not like an implicit first parameter.

While the "Resolution" paragraph differs from the final "Accepted" 
paragraph, I would take this to mean that the change to use r8 was 
accepted. It looks like this change never got incorporated in the ABI 
spec.

What does the C++ ABI test suite check for?

-cary




More information about the cxx-abi-dev mailing list