how to pass params to inline functions by reference or value?

Eljay Love-Jensen eljay@adobe.com
Thu Apr 10 15:11:00 GMT 2008


Hi Vincent,

> However, IF the function is inlined, no copying should actually take
> place because the arg is not modified within the function. My guess is
> that [#1] these will produce identical code.

Is the context C++ or C?

For C++, that [#1] is incorrect for non-regular types, and likely incorrect
for regular types.  (But for C++ you probably should use a const& for the
inline function's parm, which would do what you want.)

For C, I'm not sure, but I suspect that [#1] is incorrect.

What happens when you test compile the two variants with --save-temps and
-O2, and look at the resulting .s files?

HTH,
--Eljay



More information about the Gcc-help mailing list