-qoldpassbyvalue

C++ only

Description

Specifies how classes containing const or reference members are passed in function arguments. All classes in the compilation unit are affected by this option.

Syntax

Read syntax diagramSkip visual syntax diagram        .-nooldpassbyvalue-.
>>- -q--+-oldpassbyvalue---+-----------------------------------><

See also #pragma pass_by_value.

Notes

VisualAge C++ v5.0 and later compilers use pass by value if the copy constructor is trivial and the destructor is trivial, regardless of const or reference data members. IBM C/C++ Compilers v3.6 uses pass by value only if the class has no const or reference data members, and the copy constructor is trivial and the destructor is trivial.

When -qoldpassbyvalue is specified, the compiler mimics the IBM C/C++ Compilers v3.6 compiler in that when a class containing a const or reference member is passed as a function argument, it is not passed by value. All such classes in the compilation unit are affected.

The #pragma pass_by_value directive overrides -qoldpassbyvalue, and gives you additional control in enabling this feature.

Use this option if you are linking to libraries compiled with IBM C/C++ Compilers v3.6 or earlier. Otherwise, functions that have class parameter types of this kind will give incorrect behavior when they are called from modules compiled with a later version of the compiler. Library headers compiled with IBM C/C++ Compilers v3.6 or earlier should be protected with the #pragma pass_by_value directive so that users of these libraries will get the correct calling convention for functions in those libraries that use class parameters.

Related information