HP aC++/HP C A.06.25 Programmer's Guide
to an HP aC++ program. In addition to keyword changes, there are changes in C++
Semantics and C++ Syntax.
Changes in C++ Semantics
Following lists the differences in code behavior when you migrate from HP C++ to HP
aC++:
• Implicit Typing of Character String Literals
• Overload Resolution Ambiguity of Subscripting Operator
• Execution Order of Static Constructors in Shared Libraries
• More Frequent Inlining of Inline Code
NOTE: These differences can occur inspite of compiling your code without errors.
Implicit Typing of Character String Literals
HP C++ implicitly types character string literals as char *. HP aC++, in accordance
with the ANSI/ISO C++ International Standard, types character string literals as
const char *. This difference affects function overloading resolution.
Example:
In the following code, HP aC++ calls the first function a; cfront calls the second.
void a(const char *);
void a(char *);
f() {
a(“A_STRING”);
}
To prevent existing code from breaking, assign a string literal to a non-const pointer.
Example:
char *p = “B_STRING”;
NOTE: This feature may not be a part of the Standard in future revisions.
Also, you cannot convert const char * to char *in a conditional expression in this
context.
Example:
char *p = f() ? “A” : “B”;
In such a scenario, you must change the code.
Example:
const char *p = f() ? “A” : “B”;
or
char *p = const_cast(f() ? “A” : “B”);
Migration Considerations Related to Standardization 275