initialization of a reference type generates an error and the program does not compile. To avoid this error, use a constant reference.

Example:

void f() { char c = 1; int & r = c;

}

Compiling the above code with HP C++ generates the following warning:

C:“nonConstRef.C”, line 6: warning: initializer for non-const reference not an lvalue (anachronism) (235)

Compiling the code with HP aC++ generates an error like the following:

Error: File “nonConstRef.C”, Line 6

Type mismatch; cannot initialize a ‘int &’ with a ‘char’.

Try changing ‘int &’ to ‘const int &’.

To successfully compile with both compilers, make the following changes to the code:

void f() { char c = 1;

const int & r = c;

}

Using operator new to Allocate Arrays

In HP C++, operator new is called to allocate memory for an array. In HP aC++, operator new [] is called to allocate memory for an array.

Example:

The following code compiles without error on HP C++.

typedef char CHAR;

typedef unsigned int size_t; typedef const CHAR *LPCSTR, *PCSTR; typedef unsigned char BYTE;

void* operator new (size_t nSize, LPCSTR lpszFileName, int nLine); static char THIS_FILE[] = “mw2.C”;

int main() { BYTE *p;

p = new(THIS_FILE, 498) BYTE[50];

}

On HP aC++, the following error is generated:

Error: File “DDB4269.C”, Line 10

Expected 1 argument(s) for void *operator new [ ](unsigned int); had 3 instead.

Parentheses in Static Member Initialization List

In HP C++, redundant parentheses are allowed in a static member initialization list. In HP aC++, redundant parentheses in a static member initialization list generate an error and the program does not compile. You must remove the redundant parentheses to compile the program with both compilers.

Example:

class A { public:

int i;

static int (A::*p);

};

int (A::*(A::p)) = &(A::i);

Compiling this code HP aC++ generates the following error:

Migration Considerations Related to Standardization 217