HP aC++/HP C A.06.20 Programmer's Guide

>
int main(){
}
Duplicate Formal Argument Names
In HP C++, duplicate formal argument names are allowed. In HP aC++, duplicate formal
argument names generate an error. To avoid this, use unique formal parameter names.
Example:
The following code compiles with HP C++. With HP aC++, an error is generated stating
that symbol aParameter has been redefined and where it was previously defined.
int a(int aParameter, int * aParameter);
Ambiguous Function or Object Declaration
In HP C++, an ambiguous function or object declaration compiles without warning,
assuming an object declaration. In HP aC++, an ambiguous function or object declaration
generates an error. To change this, change the code to remove the ambiguity.
Example:
struct A {A(int);};
struct B {B(const A &); void g();};
void f(int p) {
B b(A(p)); // Declaration of function or object?
b.g(); // Error?
}
The ambiguity in the example code is whether b is declared as:
A function with one argument (named p) returning an object of type B.
An object of type B initialized with a temporary object of type A.
HP C++ compiles this code successfully and assumes b is an object. Compiling the code
with HP aC++ generates the following error:
Error: File objDeclaration.c, Line 5
Left side of . requires a class object; type found was a function B (A).
Did you try to declare an object with a nested constructor call?
Such a declaration is interpreted as a function declaration B b(A)
[File objDeclaration.c, Line 4].
Modify the code as shown below to successfully compile it with both compilers.
struct A {A(int);};
struct B {B(const A &); void g();};
void f(int p) {
B b = A(p); // declaration of object
b.g(); // method call
}
Migration Considerations Related to Standardization 281