compatTempAccessChecking Language Option (C++)

Syntax: Default:
lang(compatTempAccessChecking[, yes])
lang(compatTempAccessChecking, no)
lang(compatTempAccessChecking[, yes])

This option controls whether access to a copy constructor to create a temporary object is always checked, even if creation of the temporary object is avoided.

By default, VisualAge C++ suppresses the access checking. This is an extension to the C++ standard and gives behavior that is compatible with the C++ compilers provided by VisualAge C++ for OS/2 3.0, VisualAge for C++ for Windows version 3.5, and Microsoft Visual C++.

When this option is set to yes, you receive a warning if your code uses the extension, unless you disable the message. Disable the message by building with report(disable, "CPPC0306") when the copy constructor is a private member, and report(disable, "CPPC0307") when the copy constructor is a protected member.

Set compatTempAccessChecking to no for compliance with standard C++. For example, the throw statement in the following code causes an error because the copy constructor is a protected member of class C:

class C {
public:
   C(char *);
protected:
   C(const C&);
};

C foo() {return C("test");}  // returns a copy of a C object 
void f()
{
// catch and throw both make implicit copies of the thrown object
   throw C("error");         // throws a copy of a C object
   const C& r = foo();       // uses the copy of a C object created by foo()
}

The example code above contains three ill formed uses of the copy constructor C(const C&).



Incremental C++ Build
Configuration Files


Set Build Options
Build


Language Options for C++
Build Options
Build Options for Compliance With the C++ Standard
Build Options for Compatibility with Old C++ Compilers