HP aC++/HP ANSI C A.06.
© Copyright 2011 Hewlett-Packard Development Company L.P. All rights reserved Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice.
Contents 1 HP aC++/HP ANSI C release notes...........................................................................................7 2 What’s new in this version........................................................................................................8 Improved GNU compatibility and new GNU features....................................................8 Support for GNU statement expression...................................................................8 Support for _Pragma ("once")........
New diagnostic messages (New).........................................................................21 Improved diagnostic messages (Changed)............................................................22 Enhanced +wendian warnings (New/Changed)....................................................22 New runtime abort messages (New)....................................................................23 New features in version A.06.20.............................................................................
__attribute__ ((warn_unused_result)) Added (New).................................................40 Change in treatment of cv-qualified assignment operators.......................................40 New features in version A.06.12...............................................................................40 +Ofast (-fast) and +Ofaster options......................................................................41 Interaction between +Oinit_check and +check=uninit...........................................
Online C++ example source files.........................................................................56 Other documentation.........................................................................................56 HP aC++ world wide web homepage..................................................................56 HP C world wide web homepage........................................................................
1 HP aC++/HP ANSI C release notes The information in this document applies to the release of HP aC++ and HP ANSI C compilers for the HP-UX 11i v3 operating system on Integrity servers. The HP ANSI C compiler supports ANSI programming language C standard ISO 9899:1999. HP aC++ compiler supports the ISO/IEC 14882 Standard for the C++ Programming Language (the international standard for C++). HP ANSI C and HP aC++ are distributed as a single software bundle.
2 What’s new in this version This chapter gives an overview of the product changes in this version of the HP aC++/HP C compiler. HP aC++/HP C compiler version A.06.26 provides leading edge support for C++0x standard language features, with complete binary compatibility with earlier releases and -AA compilation mode. Following are the changes in HP aC++/HP C compiler version A.06.
Example 1 Expression in default compilation mode ({ int y = foo (); int z; if (y > 0) z = y; else z = - y; z; }) This is a valid expression for the absolute value of foo (). The last item in the compound statement should be an expression followed by a semicolon (;). The value of this sub-expression serves as the value of the entire construct. Support for _Pragma ("once") The _Pragma ("once") operator is equivalent to #pragma once.
Example 3 Redirecting make-dependency to a file aCC +Makef make_dependency_output_file source_file aCC +Makef hello.make-dep hello.c Support for initialization of Flexible Array Member The compiler now supports the initialization of Flexible Array Member. Following are the characteristics of this implementation: • Flexible array members are written as contents[] without the 0. • Flexible array members have incomplete type, and so the sizeof operator may not be applied.
Frequently Asked Questions under C++ runtime environments (-AA and -AP) on HP-UX. • -Aarm This enables some cfront semantics. But cfront was obsoleted in 1997. Code should long have been ported to Standard C++. • +O[no]signedpointers This was only useful for rare cases on PA-RISC. The C++ Standard requires pointers to be treated as unsigned when comparing them.
• +O[no]report This option is useful only on PA-RISC systems. • +df This is an option used on PA-RISC systems, and is replaced by +Oprofile=use[:filename]. • +ES[no]lit This is an option used on PA-RISC systems, and is replaced by +Olit=all / +Olit=none. • +M[d] / +m[d] These are options used in PA-RISC aC++, and are replaced by the longer +Make[d] and +make[d] forms to prevent confusion with the unrelated previous +m in HP C. • +O[no]all This option was deprecated earlier.
3 Product changes in earlier versions New features in version A.06.25 Version A.06.
• Improved diagnostic messages (Changed) • Enhanced +wendian warnings (New/Changed) • New run-time abort messages (New) C99 default C compilation mode (Changed) In this version of the HP C/aC++ compiler, the default C compilation mode has changed from C89 to C99. So by default C99 features are enabled, and the following commands are now equivalent: cc cc -Ae cc -AC99 aCC -Ae aCC -AC99 To retain the previous behavior, use the -AC89 command-line option.
error #2020: identifier "i" is undefined • Reference to outer scope variable instead of loop index: warning #2780-D: reference is to variable "i" (declared at line X) [Under old for-init scoping rules it would have been variable "i" (declared at line Y)] With +wlint: warning #3348-D: declaration hides variable "i" (declared at line X) To catch issues resulting from this change in the C++ default, compile with the +We2780 option to convert the warning 2780 to an error.
Example: template struct S { static_assert(sizeof(T) > 4, "Type too small"); }; S s1; // Will trigger an error when the static_assert // declaration is instantiated. Extended friend types Support is now included for extended friend declaration syntax which allows for non-class names and non-elaborated class names to be declared as friend.
C++0x relaxes that restriction to allow such names as an unevaluated operand, such as sizeof(X::m), typeid(X::m), and decltype(X::m). With this release, aC++ now accepts this usage in C++0x mode and non-strict C++98/03 mode; such references are transformed into a compiler-generated member-access expression using 0 cast to the appropriate type as the object pointer.
function typically encloses the runtime state or environment of the declaring function, being therefore able to access the local variables of the current function. The way these variables are accessed can be controlled using either the '&' in a lambda capture list ([&]), in which case the variables are passed by reference; by using a '=' ([=]), whereby the variables are simply copied (analogous to call-by-value); or a combination of the two.
# define PRINTF(...) printf (__VA_ARGS__) int main() { char* from = "aCC"; PRINTF("Hello, World" " from %s!\n", from); return 0; } // This will print: // Hello, World from aCC! _Pragma operator The _Pragma operator (originally from C99 and already supported in GNU mode), is now supported in non-strict C++98/C++03 mode and in all C++0x modes. The operator has the effect of expanding the pragma specified in the string (in double-quotes) in just the way a #pragma would.
For more information on using Decimal FP, see the release notes section "Decimal floating-point arithmetic supported" under "New Features in the A.06.20 Release." #pragma STDC FLOAT_CONST_DECIMAL64 (New) #pragma STDC FLOAT_CONST_DECIMAL64 [ON | OFF | DEFAULT] With this pragma set to OFF, unsuffixed floating-point constants are treated as having type double. With this pragma set to ON, unsuffixed floating-point constants are treated as having type _Decimal64.
firstprivate (list) shared (list) #pragma omp taskwait (New) #pragma omp taskwait new-line The OpenMP 3.0 directive #pragma omp taskwait specifies a wait on the completion of child tasks generated since the beginning of the current task. Because the taskwait construct does not have a C language statement as part of its syntax, there are some restrictions on its placement within a program. The taskwait directive may be placed only at a point where a base language statement is allowed.
int main(){ int something; \ int anotherthing; } line 2: warning #3750-D: "\" followed by white space is not a line splice • Warning #2767 In 64-bit C compilations, casting a pointer to an integral type of lower size now generates warning #2767. Previously, this was only a remark. • Remark #3719 In cases where the constructor initialization list is invoked in an order different from what the programmer apparently expects, a new remark #3719 is now emitted.
4291: endian porting: the read/write of the buffer may be endian dependent 4292: endian porting: the dereference of cast pointer may be endian dependent • A new warning, 4364, is added to capture cases where a cast when dereferenced later can cause endian issues: 4364: endian porting: type cast is endian dependent New runtime abort messages (New) The following enhancements will be available in aC++ Runtime patches PHSS_40543 (11.23) and PHSS_40544 (11.
• In next release, default C compilation mode will change from C89 to C99 • In next release, default C++ compilation mode changes to full -AA Decimal floating-point arithmetic (HP-UX 11.31 only) (New) On HP-UX 11.31 systems, support is now included for decimal floating-point arithmetic for C. This support follows the current draft revision of the IEEE 754 floating-point standard and ISO/IEC Technical Report 24732, Extensions for the programming language C to support decimal floating-point arithmetic.
compiler uses, and the "decimal encoding". Both encodings provide exactly the same data, analogous to big endian and little endian encodings. • Decimal FP I/O and string conversion. The decimal FP length modifiers for printf() and scanf() floating-point conversion specifiers (a, A, e, E, f, F, g, G) are H for _Decimal32, D for _Decimal64, and DD for _Decimal128.
• To use the decimal FP functionality in , , , or , define __STDC_WANT_DEC_FP__ before including the header. • To use strtod32, strtod64, or strtod128, include . (These interfaces are not declared in , as specified in the ISO/IEC C draft Technical Report.) • Also see the “HP-UX floating-point guide for HP Integrity servers” at http:// www.hp.com/go/fp.
const _Decimal64 onert = 0.0DD; // for rounding to tenths const _Decimal64 twort = 0.
h = quantized64(h, onert); // round to tenths // compute billing amount fe_dec_setround(FE_DEC_TONEARESTFROMZERO); b = rate * h; b = quantized64(b, twort); // round to hundredths // restore decimal rounding mode to default fe_dec_setround(FE_DEC_TONEAREST); // print billing amount to file fprintf(outp, "%Da\n", b); // update sums sumM += m; sumH += h; sumB += b; } // main loop // close files fclose(inp); fclose(outp); // confirm expected quantum in sums assert(samequantumd64(sumH, onert)); assert(samequantu
+annotate=structs (New) The +annotate=structs option annotates the compiled binary with accesses to C/C++ struct fields for use by other external tools such as Caliper. By default, no annotations are added. +check=lock (New) The new runtime +check=lock option enables the checking of locking discipline violations; for example, whether appropriate locks are held when threads access shared data in applications using Posix threads. Refer the online programmer's guide for additional detail and code example.
+O[no]dynopt (HP-UX 11.31 only) (New) On HP-UX 11.31 systems, the +O[no]dynopt option enables [disables] dynamic optimization for the output file. Both forms of this option change the default setting, which allows the run-time environment to enable or disable dynamic optimization according to a system-wide default. This option applies only to executable files and shared libraries, if the run-time environment supports this feature.
#pragma diag_pop (New) This pragma restores the severities of all diagnostics to the state prior to the last #pragma diag_push. A compilation unit should have an equal number of #pragma diag_push and #pragma diag_pop uses. +Oinlinebudget is deprecated (Change) The +Oinlinebudget option is deprecated in this release and will not be supported in future releases. Use +inline_level.
error #2020: identifier "i" is undefined • Reference to outer scope variable instead of loop index: warning #2780-D: reference is to variable "i" (declared at line X) -under old for-init scoping rules it would have been variable "i" (declared at line Y) With +wlint: warning #3348-D: declaration hides variable "i" (declared at line X) By also compiling with +We2780, the two errors, 2020 and 2780, should catch any issues resulting from the change in the C++ default.
• __attribute__ ((visibility("default"|"protected"|"hidden"))) (New) • __attribute__ ((warn_unused_result)) (New) • Change in treatment of cv-qualified assignment operators printf, fprintf optimization (New) For optimization level+O2or above, printf and fprintf calls are now optimized into fputc or fputs calls, in trivial cases. This optimization will only occur when both the following are true • A return value is not used for printf and fprintf. For example, use (void)fprintf(...
level, the more messages are generated. Level 1 emits only the most important messages, while level 4 emits all the messages. If the optional level is not specified, it defaults to 2. +Wv option (New) +Wv[d1,d2,...,dn] The new +Wvoption displays the description for diagnostic message numbers d1,d2,...,dn. Specifying this option causes HP Code Advisor to emit the descriptive text for the specified diagnostics to stderr. This option must not be used with any other compiler options.
for loops that have not been parallelized manually with OpenMP directives. For these loops, the compiler automatically parallelizes each loop that is both safe and likely to have improved performance when executed in parallel. Programs compiled with the +Oautopar option require the libcps, libomp, and libpthreads runtime support libraries to be present at both compilation and runtime. When linking with the HP-UX B.11.
Using an array will force the string to be read/write.
This form differs from+pathtrace=global because the size of the table cannot be configured at runtime, and the contents cannot be dumped to a file. The fixed-size global path table has better runtime performance than the configurable global path table. The performance difference varies depending on the optimization level and how the program is written. none Disables generation of both the global and local path tables. The values can be combined by joining them with a colon.
The +check=globals option is implied by +check=all. • +check=truncate[:explicit|:implicit] The +check=truncate option enables runtime checks to detect data loss in assignment when integral values are truncated. Data loss occurs if the truncated bits are not all the same as the left most non-truncated bit for signed type, or not all zero for unsigned type. Programs may contain intentional truncation at runtime, such as when obtaining a hash value from a pointer or integer.
This option is the same as -Bhidden, but only locally defined (non-tentative) symbols, without __declspec(dllexport), are assigned the hidden export class. As with any -B option, -Bhidden_def can be overridden by subsequent -B options on the command line or any binding pragmas in the source. -dM (New) -dM The -dM option requires that-P or -E also be specified.
Debugging Code Compiled with Opt Levels above +O1 Is Supported Debugging code compiled with optimization levels above +O1is now supported, as described in section 14.22 ("Debugging optimized code") of the Debugging with GDB manual under the "Documentation" link at: http://www.hp.com/go/wdb.
+Ofast (-fast) and +Ofaster options The +Ofast and +Ofaster options now cause the data and text page size to be 1MB instead of 4MB, for increased performance The +Ofast option no longer implies the unsafe optimizations +Ointeger_overflow=aggressive and +Olibcalls.
HP Code Advisor This release introduces a new tool "HP Code Advisor", that can be used for detecting various programmer errors in C/C++ source code. Use this tool to identify potential coding errors, porting issues and security errors. The HP Code Advisor is being made available on both HP-UX PA and Integrity servers. It leverages the advanced analysis capabilities of the C/C++ compilers for the Integrity servers. Use "/opt/cadvise/bin/cadvise" to invoke the tool.
This allows you to turn off libcall optimizations (inlining or replacement) for calls to the listed functions. This overrides system header files. +wendian option (New) This option allows the user to identify areas in their source that might have porting issues when going between little-endian and big-endian. +wlint option (Enhanced) New diagnostic features have been added for this option.
NOTE: No configuration files are shipped along with aC++, but can be installed by the system administrator, if required. [NO]PTRS_TO_GLOBALS pragma #pragma [NO]PTRS_TO_GLOBALS This pragma aids alias analysis. It must be specified at global scope and immediately precede the declaration of the variable or entry named. The pragma tells the optimizer whether the global variable or entry "name" is accessed [is not accessed] through pointers.
C++ Standard library change Technical Corrigenda 1 has changed the STL function make_pair to take their arguments by value instead of const reference. This change brings the HP library into compliance if the enabling macro -D__HP_TC1_MAKE_PAIR is specified at compile time. For binary compatibility reasons, the default behavior is unchanged. Earlier versions Information on features introduced in versions before A.06.
4 Installation information Read this entire document and any other release notes or readme files you may have before you begin an installation. To install your software, run the SD-UX swinstall command. This invokes a user interface that will lead you through the installation. For more information about installation procedures and related issues, refer Managing HP-UX Software with SD-UX and other README, installation, and upgrade documentation provided or described in your HP-UX 11.
5 Compatibility information Maintaining binary compatibility is a key release requirement for new versions of HP aC++. The compiler has maintained the same object model and calling convention and remains compatible with the HP-UX runtime in the code that it generates as well as its intrinsic runtime library (libCsup) across the various releases of HP aC++ and its run-time patch stream.
printf("%d\n",sizeof(A)); } Migrating from HP C++ (cfront) to HP aC++ The compiler lists Errors, Future Errors, and Warnings. Expect to see more warnings, errors and future errors reported in your code, many related to standards based syntax. For more complete information, refer the HP aC++ Transition Guide at http:// www.hp.com/go/aCC. General programming information and support questions For general background information and experience, subscribe to the cxx-dev list server (like a notes group).
6 Known problems and workarounds This section describes known problems and workarounds. Customers on support can use the product number to assist them in finding SSB and SRB reports for HP aC++ or HPC. The product number you can search for is B3910BA. To verify the product number and version for your HP aC++ or HP C compiler, execute the following HP-UX commands: what /opt/aCC/bin/aCC what /opt/aCC/lbin/ecom Obsolete LANG-STARTUP files As of HP aC++ version A.06.
ld: The value 0xXXX does not fit when applying the relocation GPREL22 for symbol "variable" at offset 0xYYY in section index ZZZ of file bar.o. Workaround: The declaration should be changed to: extern uint64_t variable[]; This error can also occur in assembly code if items <= 8 bytes are put into.data/.bss instead of .sdata/.sbss. Workaround (assembler): For "small" variables defined in assembly, change the section name from .bss to .sbss or .data to .sdata: .section .sdata = "asw", "progbits" .
int main() {} // end of test.c The following flags are now automatically set with A.05.* and A.06.* compilers: • -D__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL • -D__HPACC_THREAD_SAFE_RB_TREE • -D__HPACC_USING_MULTIPLIES_IN_FUNCTIONAL • -D__HPACC-FIX_FUNC_ADAPTER_OPERATOR • -D__HPACC_FULL_ITERATOR_REL_OPS • -D__HPACC_TEMPLATE_PAIR_CTOR • -D__HPACC_MEM_FUN_ADAPTOR Conflict between macros.h and numeric_limits class (min and max) If your code includes /usr/include/macros.
defines a dummy function that has a parameter of that type (Widget) and link it into the executable program. • • Known limitations of exception handling features: ◦ Interoperability with setjmp/longjmp (undefined by the ISO/ANSI C++ international standard) is unimplemented. Executing longjmp does not cause any destructors to be run.
This will insure that, when the application is migrated to a system that has a later version of libA available, the actual version desired is the one that is dynamically loaded. • Memory Allocation Routine alloca() The compiler supports the built in function, alloca, defined in the /usr/include/alloca.h header file. The implementation of the alloca() routine is system dependent, and its use is not encouraged. alloca() is a memory allocation routine similar to malloc() (see malloc(3C)).
7 Related documentation Documentation for HP aC++ / HP C is described in the following sections. Online documentation The following online documentation is included with the HP aC++/HP C products: • HP aC++ Programmer’s Guide Access this guide in any of the following ways: ◦ Use the +help command-line option: /opt/aCC/bin/aCC +help ◦ From your web browser, enter the appropriate URL: file:/opt/aCC/html/C/guide/index.
The reference is provided as HTML formatted files. You can view these files with an HTML browser by opening the file /opt/aCC/html/libstd_v2/stdref/ index.htm or select the hyperlink from HP aC++ Programmer’s Guide. • Rogue Wave Software Standard C++ Library 2.2.1 User’s Guide This guide gives information about library usage and includes an extensive discussion of locales and iostreams. The guide is provided as HTML formatted files.
NOTE: Refer the HP aC++ Online Programmer’s Guide Information Map for how to obtain additional Rogue Wave documentation and information. • HP aC++ Release Notes is this document. The online ASCII file can be found at /opt/aCC/newconfig/RelNotes/ACXX.release.notes. • Online man pages for aCC and c++filt are at /opt/aCC/share/man/man1.Z. Man pages for the Standard C++ Library and the cfront compatibility libraries (IOStream and Standard Components) are provided under /opt/aCC/share/ man/man3.Z.
HP C world wide web homepage Access the HP C World Wide Web Homepage at the following URLs: http://www.hp.