HP aC++ A.03.85 Release Notes

HP aC++ Release Notes
New Features in Version A.03.25
Chapter 1 57
+ESlit Option New Default
The +FP[flags] option specifies how the run-time environment for floating-point operations
should be initialized at program start up. The default is that all exception behaviors are
disabled. See ld(1) for specific flag values. To dynamically change these settings at run time,
see fesetenv(3M).
By default, string literal data now resides in read-only memory rather than read-write
memory. This new default may result in improved run-time performance, because read-only
memory is shared. The +ESlit command line option can be used to explicitly specify this
behavior. +ESnolit reverts to storing string literal data in read-write memory.
NOTE This new default option may cause programs to abort with signal 10 at
run-time.
String literals (quoted character strings) are typed as const char[] and programs that
attempt to modify string literal data are violating the semantics of this const type. Modifying
string literal data at the source level translates to writing data into read-only memory at
runtime and will result in the process receiving a signal 10 (bus error). Below is an example of
such a program:
void f(char *s) { // Warning 829: const char* -> char*
s[0] = ‘S’; // abort: write into read-only memory
}
int main() {
f(“string literal”);
return 0;
}
Programs that attempt to write into a string literal’s read-only memory will trigger warnings
and errors at compile-time. Fixing the program’s compile-time errors and warnings has the
benefit of enabling the use of +ESlit, thus taking advantage of improved run-time efficiency
and improving the application’s portability.
The following code generates the compile-time errors shown below:
int main() {
const char *p = “quoted string”;
char* c=p; // Error 440
void main2() {
const char *p = “quoted string”;
char* c;
c=p; // Error 203