Compaq_C++_Version_6.3________________________ Release Notes for OpenVMS Alpha July 18, 2001 This document contains information about new and changed features in this version of Compaq C++ for OpenVMS Alpha. Compaq Computer Corporation Houston, Texas __________________________________________________________ © 2001 Compaq Computer Corporation. COMPAQ, the Compaq logo, and Alpha, DEC, Ladebug, OpenVMS, and VMS are registered in the U.S. Patent and Trademark Office. Tru64 is a trademark of Compaq Information Technologies Group, L.P. in the United States and other countries. UNIX is a trademark of The Open Group in the United States and other countries. All other product names mentioned herein may be trademarks of their respective companies. Portions of the ANSI C++ Standard Library have been implemented using source licensed from and copyrighted by Rogue Wave Software, Inc. All rights reserved. Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this document is provided as is without warranty of any kind and is subject to change without notice. The warranties for Compaq products are set forth in the express limited warranty statements accompanying such products. Nothing herein should be construed as constituting an additional warranty. Confidential computer software. Valid license from Compaq 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. This document was prepared using DECdocument, Version 3.3-1n. ________________________________________________________________ Contents 1 Introduction................................. 1 2 Important Compatibility Information.......... 1 2.1 Run-Time Library Differences............. 1 2.2 Compiler Differences..................... 2 2.3 Differences Between Compaq C++ and the C++ International Standard............... 3 3 New Debugger................................. 5 4 Release Notes for the C++ Compiler........... 7 4.1 Enhancements, Changes, and Problems Corrected in Version 6.3................. 7 4.2 Restrictions and Known Problems in Version 6.3.............................. 12 4.3 Enhancements, Changes, and Problems Corrected inVersion 6.2A................. 12 4.4 Enhancements and Changes in Version 6.2...................................... 13 4.5 Restrictions in Version 6.2.............. 18 4.6 Enhancements and Changes in Version 6.0...................................... 18 5 Release Notes for the C++ Standard Library... 20 5.1 Enhancements and Changes, and Problems Corrected in Version 6.3................. 21 5.2 Enhancements and Changes, and Problems Corrected in Version 6.2A................ 24 5.3 Enhancements and Changes in Version 6.2...................................... 25 5.4 Problems Corrected in Version 6.2........ 27 5.5 Restrictions in Version 6.2.............. 31 5.6 Enhancements and Changes in Version 6.0...................................... 42 iii 1 Introduction This document contains the release notes for Compaq C++ Version 6.3 for OpenVMS Alpha. The Compaq C++ product requires OpenVMS Alpha Version 6.2 or higher. The Compaq C++ media contains the following: o The Version 6.3 kit, which includes the Compaq C++ compiler and associated files, such as the Class Library and Standard Library header files. o The ADX072 kit, which contains an enhanced OpenVMS Debugger that provides better debugging of applications built with the Compaq C++ compiler. HTML files are provided for the release notes and some of the product manuals for use with a web browser. To view this documentation, point your browser to file:/sys$common/syshlp/cxx$help/index.htm 2 Important Compatibility Information Compaq strives to maintain a high degree of compatibility between successive versions of the compiler and its run- time environment. Because, however, each new version includes enhancements and changes, you should be aware of the following whenever you upgrade: o Differences between Run-Time Library versions o Differences between compiler versions o Differences between Compaq C++ and the C++ International Standard The next sections discuss these differences. 2.1 Run-Time Library Differences Applications must use a version of the C++ Run-Time library that provides all the functions they require. If an application is linked shared, and the correct library version is not installed, "undefined symbol" error messages appear at run time. Changes in the Run-Time Library occurred in Versions 6.0 and 6.2. 1 For information about redistributing C++ Run-Time Library components, see Deploying Your Application in Using Compaq C++ for OpenVMS Alpha. 2.2 Compiler Differences Starting with Version 6.0, the Compaq C++ compiler differs significantly from previous versions. There are several major differences that you should be aware of before using a Version 6.n compiler for the first time. These differences are summarized here. For more detailed information, see Porting to Compaq C++ in Using Compaq C++ for OpenVMS Alpha. o Language differences The compiler implements (with some differences, as described in Section 2.3), the C++ International Standard, which differs significantly from the language specified in the ARM (The Annotated C++ Reference Manual, 1991, by Ellis and Stroustrup) and implemented by the Version 5.n compilers. When switching from a Version 5.n compiler, you might need to modify your source files, especially if you use the default language mode. In addition, language changes can affect the run-time behavior of your programs. If you want to compile existing source code with minimal source changes, compile using the /standard=arm option. See Porting to Compaq C++ in Using Compaq C++ for OpenVMS Alpha. ________________________Note ________________________ The installation procedure checks whether a Version 5.3 to 5.6 compiler is installed on your system. If so, it asks whether you want to save it, and if so, where. The default save area for a Version 5.6 compiler is SYS$COMMON:[CXX056]. If you find that Version 6.n requires excessive changes to your applications even when you use the /standard=arm option, or if you encounter problems using the Version 6.n compiler, you can return to your previous C++ environment by invoking the command procedure 2 SYS$COMMON:[CXX0nn]COMPILER_SETUP.COM where nn specifies the version of your previous compiler. _____________________________________________________ o Diagnostic differences The Version 6.n compiler does more error checking than Version 5.6 and generates more diagnostics. If you want the number of diagnostics issued by the Version 6.n compiler to be similar to Version 5.6, compile with the /quiet option. See Message Control and Information Options in Using Compaq C++ for OpenVMS Alpha. o Implementation differences The automatic template instantiation model has been redesigned for the current version. Although code compiled with Version 5.n and 6.n compilers can be combined, you must complete the Version V5.n instantiation process with a V5.n compiler before linking to code compiled with Version 6.n. See Using Templates in Using Compaq C++ for OpenVMS Alpha. 2.3 Differences Between Compaq C++ and the C++ International Standard The following items, specified in the C++ International Standard, are not supported in Version 6.3 but will be supported in a future version. Details about each item are provided in the indicated sections of the C++ International Standard document and The C++ Programming Language, 3rd Edition by Bjarne Stroustrup. o The export keyword for templates (Standard §14, paragraph 6; Stroustrup §9.2.3) o No cname version of headers provided (Standard §17.4.1.2; Stroustrup §16.1.2) Compaq C++ does not currently provide versions of the 18 ISO C library headers because no standard- conforming mechanism has yet been defined. Once such a mechanism is available, we plan to use it, rather than have the version incorrectly include the non- version. 3 The C++ header file inclusion policy for treating ISO C Library headers specifies that for each of the 18 ISO C headers, C++ should provide a form and a form. The version defines all the symbols defined by ISO C in the corresponding header in the std namespace. The header defines all the symbols defined by ISO C in the corresponding header in both the std and global namespace. Some of the problems are as follows: o Because C library headers contain many non-ISO C names, it is impossible to avoid polluting either the std namespace, the global namespace, or both. (Remember that the global namespace is considered a real namespace that must not be polluted.) Namespace pollution is not only incorrect, it can lead to unexpected ambiguities. Consider the following program, which includes and directly. #include // name.h includes types.h & brings it into std:: #include // types.h in global namespace using namespace std; use something from types // ambiguity o Synchronizing the release of C and C++ headers. o C++ inherits and must work around bugs in the C headers. Compaq continues to investigate methods for providing this functionality in a way that ensures long-term compatibility with various C and C++ mplementations. As a workaround, you can conditionalize your modules to use the versions of the headers when they become available. For example: 4 #ifndef __NO_NEW_HEADER #include #include #include #else #include #include #include #endif //__NO_NEW_HEADER 3 New Debugger A new OpenVMS Debugger (kit ADX072, dated 4-Mar-1999) is provided with the Version 6.3 kit and must be installed to debug programs compiled with Compaq C++ Version 6.3. This debugger solves several problems with the previous debugger. ________________________Note ________________________ The version of the OpenVMS Alpha operating system running on your computer determines how the ADX072 kit links debugger images when you run VMSINSTAL. When linked with Version 6.n, the ADX072 debugger does not work correctly on Version 7.n systems. For example, if you install ADX072 on a Version 6.2 system, and if you later upgrade that system to Version 7.2, the ADX072 debugger does not work correctly until you reinstall ADX072. OpenVMS Alpha releases after Version 6.2 include a debugger that supports the new C++ capabilities. If you are running OpenVMS Alpha Version 6.2 or later, consult the OpenVMS New Features Manual to determine whether you must install the debugger shipped with Compaq C++. _____________________________________________________ To install the special C++ debugger, invoke VMSINSTAL: @SYS$UPDATE:VMSINSTAL ADX072 device-name option-list See the Compaq C++ Installation Guide for OpenVMS Alpha for additional information. 5 The C++ debugger GUI image is not installed automatically on OpenVMS systems that are not running DECwindows Motif or that run a version earlier than 1.2-4. If you decide to install Motif or upgrade to Version 1.2-4 or later, and if you then want to use the debugger GUI, you must perform these tasks: 1. Reinstall the ADX072 kit to create the debugger's GUI image 2. Execute a command procedure to install the debugger images and define the default system debugger Follow these steps: If you want the special C++ debugger to be the default debugger for the system: 1. Invoke the command procedure as follows: @SYS$STARTUP:DEBUG$STARTUP_V72X.COM V72X 2. Add this line to the system startup procedure: $ @SYS$STARTUP:DEBUG$STARTUP_V72X.COM V72X 3. On OpenVMS systems prior to Version 6.2A, copy the resource file: $ COPY DECW$SYSTEM_DEFAULTS:CXXVMSDEBUG.DAT - DECW$SYSTEM_DEFAULTS:VMSDEBUG.DAT Note that C++ Version 6.n does not run on any OpenVMS versions prior to Version 6.2. If you do not want the special C++ debugger to be the default debugger for the system: 1. Invoke the command procedure as follows: @SYS$STARTUP:DEBUG$STARTUP_V72X.COM VMS 2. Add this line to the system startup procedure: $ @SYS$STARTUP:DEBUG$STARTUP_V72X.COM VMS 6 4 Release Notes for the C++ Compiler The following sections describe enhancements, changes, and restrictions for the C++ compiler environment. 4.1 Enhancements, Changes, and Problems Corrected in Version 6.3 Enhancements, changes, and problems corrected are as follows: o In strict_ansi mode, the name of a class is now entered as a member of itself, as required by clause 9 (para 2) of the Standard; this behavior is implemented more or less as an implicitly declared member typedef and might cause some existing programs to fail. For example: namespace std { class iterator {}; } struct tree { struct iterator {}; struct nested : public std::iterator { // Compaq C++ 6.2 and below thinks this is tree::iterator // Compaq C++ ?? in strict_ansi mode thinks this is std::iterator nested(const iterator&); }; }; [6613] o The error "incompatible parameter", issued when there is a difference in sign between pointers, has been made discretionary. As a result you can now reduce/increase the severity of this message or enable/disable it using its error tag incompatibleprm or its error number. The same can also be done by enclosing the offending code in #pragma. For Example, the error message for the following program can now be controlled. 7 void f(unsigned int *i) { } void main() { f((int *)0x05); } In addition, specifying -std gnu reduces the message severity to warning. o The undocumented operator char*(), which converts a String to a pointer to char in the non-standard String class has been conditionalized with the macro __DEC_ STRING_COMPATIBILITY so that it is available only when the program is compiled with the macro defined. This operator has been conditionalized beccause it allows passing a String object to functions like istream::get() or istream::getline() that expect a pointer to char. The String::operator char*() returns a pointer to the "data component" of the String, which is a private data member inside the String class. When a String object is passed to a function expecting a pointer to char, the function cannot determine how much memory has been allocated by the String, and the String cannot determine the status of the exposed pointer and the memory to which it points. This design flaw in the non-standard String class has been fixed in a way that leaves the legacy functionality available as an option. The standard ANSI C++ String class, for example, lets users retrieve only a const char*, not a char*, to the pointer owned by the String. [10.1563] o In response to user requests, CXXLINK by default now deletes the option file SYS$DISK[]CXX_REPOSITORY.OPT that previously remained in the user's current directory on completion of CXXLINK. To support this change, CXXLINK creates a unique prefix for the repository .OPT filename in the following format: .OPT 8 For example, if the node name is MYNODE and the PID is 020204AEA, the file name would be MYNODE020204AEA.OPT. This option file is created in the [.CXX_REPOSITORY] directory, if one exists. If the [.CXX_REPOSITORY] directory does not exist, the .OPT file is created in the user's current directory. CXXLINK passes this file to LINK as the second file specified on the LINK command. To preserve LINK's directory search order, the directory specification of the first file is prefixed to the name of the second file, if a second file is specified. Depending on the CXXLINK option selected, CXXLINK deletes this .OPT file by default, or renames it to CXX_REPOSITORY.OPT or to a user-specified file name. For detailed information on CXXLINK options, type HELP CXXLINK or point your browser to CXXLINK. [7135] o In Version 6.2, signaling of VMS exceptions or a C signal might cause a program to terminate with %CXXL- F-TERMINATE status regardless of which VMS exception or C signal has been raised and regardless of whether a VMS exception handler or C signal handler has been established. For example, the following test1.cxx program calling lib$stop(SS$_MCNOTVALID) terminates with %CXXL-F- TERMINATE: #include #include main() { lib$stop(SS$_MCNOTVALID); } $ run test1 %CXXL-F-TERMINATE, terminate() or unexpected() called %TRACE-F-TRACEBACK, symbolic stack dump follows image module routine line rel PC abs PC ... Similarly, the following test2.cxx program, establish- ing a C signal handler to catch a SIGILL signal, also terminates with %CXXL-F-TERMINATE without a signal handler being invoked: 9 #include #include static void signal_handler(int x) { puts("signal arrived"); } void main() { signal(SIGILL, signal_handler); raise(SIGILL); } Version 6.3 corrects this behavior: the C++ run-time environment no longer issues a call to terminate() if a VMS exception (possibly, generated by a raise() or gsignal() function arrives. Instead, the exceptions is resignaled to the next exception handler, and the exception is handled properly. For example, the test1.cxx program now correctly terminates with the OpenVMS condition value specified in the call to lib$stop() as follows: $ run test1 %SYSTEM-F-MCNOTVALID, device microcode is not valid %TRACE-F-TRACEBACK, symbolic stack dump follows image module routine line rel PC abs PC ... And test2.cxx now catches the signal and terminates correctly as follows: $ run test2 signal arrived $ [7550, 8234] o The compiler can no longer generate machine code listing when requested to not produce object files. [8448] o CXXLINK no longer incorrectly concatenates arguments passed to it if such arguments are defined as logical names. [8467] 10 o CXXLINK now correctly handles filenames when using extended ODS-5 file parsing. [8626] o In the ANSI object model (/model=ansi), string literals are treated as pointers to const char (const char *). In the ARM object model (/model=arm, the default), string literals continue to be treated as pointers to char (char *). [8659] o To generate the correct code to make calls to virtual functions that return a structure, class, or union, the compiler needs the full definition of the type returned, which is missing in the following code fragment: struct Cities; struct Storage { int x; virtual Cities visit() = 0; }; struct Reader : virtual Storage { Cities visit(); }; struct T2 : Reader { }; extern void ggg(Storage *); void fff(void) { Storage *s = new T2(); s-x = 23; ggg(s); } Because the complete definition for the type Cities is missing, the compiler cannot correctly generate the code that allows ggg() to call s-visit() for all possible definitions of the type Cities. Previous compiler versions generated code that worked for some definitions of Cities but not for others. 11 The current version of generates a diagnostic when it encounters a situation: virtual Cities visit() = 0; ...................^ %CXX-E-INCTYPPREVIRTAB, The incomplete type Cities precludes correct generation of the virtual table for the type Reader. Supply the complete type definition for Cities or use /MODEL=ANSI. at line number ... in file ... If you provide the definition of the type Cities in the module that generates this diagnostic, the compiler can generate the correct code. This code generation problem has been corrected in the ANSI object model. It could not be corrected in the ARM object model because an model incompatibility would have resulted. [8668] 4.2 Restrictions and Known Problems in Version 6.3 If you compile and link with /MODEL=ANSI and then try to use the VMS debugger to access members of a virtual base class, you might see this error: %DEBUG-E-INTERR, debugger error in DBG$GET_BASE_CLASS_OFFSET: can't find __bptr or session corruption The error is displayed because the debugger has not yet been updated to understand the new internals of the ANSI object model. 4.3 Enhancements, Changes, and Problems Corrected inVersion 6.2A Enhancements, changes, and problems corrected are as follows: o The compiler now generates code that reports a static data member as an undefined symbol at link time if the data member is referenced but not defined. [CXXC_BUGS 6826] o The new cxxlink design implemented in Version 6.2 to use .olbs instead of objects is not a general solution. The default behavior of cxxlink was changed back to using objects (/prelink=use_object_files) and the switch /prelink=use_olb was added to obtain the new 12 mechanism. The new mechanism was simplified for better performance. No attempt is made to try alternative link methods if the link fails; the default link must be used. [6804, 6795, 6583, 5997] o In the C++ Version 6.1 compiler, some objects might have their exception unwinding information set to a negative index in the cleanup table. This condition generates the following message: Unexpected dtor_block_tag in do_dtor_cleanup [7091] 4.4 Enhancements and Changes in Version 6.2 This release solves several problems in earlier versions of the compiler and includes an updated OpenVMS debugger (dated 4-Mar-1999) that solves problems with the previous debugger. Enhancements and changes are as follows: o Support for explicit template function arguments. o Improved EV6 support. o CXXLINK creates an object library. CXXLINK now creates an object library (CXX$LINK.OLB) in the writeable repository directory. The object library is populated with all object files found in the repository. CXXLINK also checks any other repository directory listed on the command line (by use of /REPOSITORY= qualifier) for CXX$LINK.OLB object libraries. Each object library is then used as input to the OpenVMS Linker through LNK$LIBRARY logical names. In most cases, the OpenVMS Linker can resolve any missing instantions by searching the object libraries. CXXLINK can then proceed directly to the final link, without having to parse the linker output looking for unresolved symbols and their matching object files. 13 Note the following restrictions: - CXXLINK makes use of the OpenVMS Linker Utility's LNK$LIBRARY logical names to reference specific object libraries as input to the linker. If the CXXLINK command includes any form of the /USERLIBRARY, an informational message appears, and CXXLINK lists any required object libraries in a linker options file. - CXXLINK always creates and repopulates the object library. For large repositories, this mechanism is slower than processing the linker output and creating the linker options file listing each object file. - CXXLINK does not create the CXX$LINK.OLB file in nonwritable repository directories. Currently, this must be done outside of CXXLINK by entering the command: $ LIBRARY/CREATE non-writeable-repository-dirCXX$LINK.OLB - non-writeable-repository-spec*.OBJ - Programs that use extern_model can encounter problems, because object files from an object library do not produce the same extern_model code that is generated when the object file is used directly. - Modules that use extern_model must be listed separately as an input to the linker. o A compiler crash caused by a label statement in a switch statement has been corrected. [6614] o If a user calls VAXC$ESTABLISH or LIBC$ESTABLISH in a function with a try/catch, the establish routine now works correctly. Note that C++ exception handling is disabled in these routines, as described in C++ Exceptions, lib$establish and vaxc$establish in Using Compaq C++ for OpenVMS Alpha. 14 o The compiler has implemented the _poppar builtin function and added code to convert output type for _poppar, _popcnt, _leadz, and _trailz to match contents of the new OpenVMS builtins.h file. See Built-In Functions in Using Compaq C++ for OpenVMS Alpha. o SCA Version 4.6-4 and later can import C++ cross reference data into its analysis data file. To import the data, follow these steps: 1. Enter the command CXX/XREF filename.cxx to have compiler emit the cross reference data file filename.xref. 2. Enter the command SCA/IMPORT filename.xref to generate filename.ana, the analysis data file. o Because of a bug introduced in Version 6.0, the compiler emitted a union layout incompatible with earilier versions if the union contained bitfield of size 8, 16, 24 . . . up to the size of the type for the bitfield. For example: typedef struct size4 { union { unsigned ttn :8; struct { unsigned incr :3; unsigned rep :5; } v1; } u; } size4; The size of size4 is 4 bytes for Version 5.7, and was incorrectly set to 1 since Version 6.0. This bug is fixed in V6.2. If you have such a bitfield in your code, you must recompile. [6567] o A problem with /extern_model=strict_refdef using template static data members and inline functions has been fixed. Previously, the compiler reported multiply defined external errors for symbols starting with __SDG and __LSG. When creating shared images, these symbols must be put in the symbol vector of the shared image. For more information, see Sample Code 15 for Creating OpenVMS Shareable Images in Using Compaq C++ for OpenVMS Alpha. [6506] o A template class name can now be reused as a non- template class in a private namespace without generating an error message. [6541] o Mangled names beginning with CXXL$ and DECC$ are now included in the demangler database and can be demangled. [6458] o More cases of unreachable code are now diagnosed. If you receive warnings you believe to be inappropriate, please report them. [6534] o The compiler no longer can exhaust virtual memory when computing the addresses of deeply nested virtual base classes. [6473] o va_start now handles parmN arguments of types that are promoted. [6471] o Some compiler-generated wrapper functions with the __STF____default_version prefix were not resolved in template automatic instantiation mode. The problem is corrected. [6362] o Debugging support for constant variables is improved. Although the compiler does not generate debug information for constant externs (because you might not be able to link), it does generate debug information for all constant variables whose underlying type is int or float o Bad code is no longer generated for an array reference within a template instantiation. [6394] o Runtime type identification has been corrected for shared images. The RTTI calls dynamic_cast and typeid now work for objects created inside OpenVMS shared images. With this correction, the name of virtual function tables have been changed to __vtbl2__, to prevent the new virtual function tables that point to RTTI information from conflicting with old tables. [6348] 16 o Debugging support is now provided for anonymous union variables inside namespaces. In the following example, debuggers support referencing s.a and s.b: struct S { union { int a; int b; } } s; In the following example, the compiler generates two variables, x and y, which the debuggers can examine. union { int x; char y[4]; }; The compiler no longer generates tag names for tagless structs and unions. o Under the following conditions, the compiler could generate code that returned the value of i before the store of the new value: 1. Take the address of a variable, using a type other than the variable's type, (p = (char *)&i). 2. Assign to the variable using a pointer addition expression, *(p + 0) = new_value. 3. Fetch the variable's value directly (return i). The problem could occur only if the store using the pointer addition expression appeared within an if statement, as in the following: int f(int flag) { int len = 1; if (flag) { char *ppp = (char *)&len; *(ppp + 0) = 2; }; return len; } The problem has been corrected. [6421] 17 o The compiler no longer generate incorrect code for offsets to external arrays. [6386] o The routine for new[] now calls delete[] if an exception occurs during construction. [6243] o Many improvements have been made to cross-reference information generated by the compiler and read by the SCA tool. o The compiler now replaces embedded line feeds with blank spaces during the initial scan. 4.5 Restrictions in Version 6.2 This release is not totally compatible with previous versions; source changes might be required. The following general restrictions apply for the current release: o The C++ International Standard permits overriding a virtual member function based only on a derived class return type. The current release does not support this capability. o Instantiating function templates with array types can result in different external name encoding than with C++ Version 5.n. To avoid link errors, recompile the template definition with the current version of the compiler. o Specifying a different long double size than the default size for your version of the operating system (using the /l_double_size qualifier) does not work correctly with the Standard Library. 4.6 Enhancements and Changes in Version 6.0 This section briefly summarizes changes and enhancements made in Version 6.0, including problems fixed. o Support for the C++ International Standard (with some differences, as described in Section 2.3), including the C++ Standard Library. See Section 5 for information on and changes to the Standard Library. o An updated debugger (dated 6-Jan-1999) that fixes problems with the previous version of the debugger. 18 o Language mode options For compatibility with previous versions, the compiler supports an ARM language mode and provides both /standard=ansi and /standard=arm language mode options, as well as options to support other C++ dialects. For details, see Porting to Compaq C++ in Using Compaq C++ for OpenVMS Alpha. o Improved automatic instantiation of templates, including: - Fewer restrictions. In particular, Compaq C++ no longer requires that template declarations and definitions appear in header files. - Build-time performance improvements that further reduce build times for applications that use templates extensively. For details, see Using Templates in Using Compaq C++ for OpenVMS Alpha. o Language feature options The compiler supports the following options: o Use of alternative tokens (see Alternative Tokens in Using Compaq C++ for OpenVMS Alpha). o Run-Time type identification (see Run-Time Type Identification in Using Compaq C++ for OpenVMS Alpha). o Performance optimization options Version 6.0 provides the following performance optimization options: o /[no]ansi_alias o /assume=[no]pointers_to_globals o /assume=[no]trusted_short_alignment o /assume=[no]whole_program For details, see Performance Optimization Options in Using Compaq C++ for OpenVMS Alpha. 19 5 Release Notes for the C++ Standard Library This section describes the enhancements, problems corrected, and restrictions for the C++ Standard Library. For information about the Compaq C++ Class Library, See Appendix A in in Using Compaq C++ for OpenVMS Alpha. The current version of Compaq C++ implements the new Standard Library string class, known as the String Library. Do not confuse this class with the String Package, which is part of the DEC C++ Class Library implemented in earlier versions of Compaq C++. Note that portions of the ANSI C++ Standard Library have been implemented in Compaq C++ using source licensed from and copyrighted by Rogue Wave Software, Inc. Information pertaining to the C++ Standard Library has been edited and incorporated into Compaq C++ documentation with permission of Rogue Wave Software, Inc. All rights reserved. Portions copyright 1994-2001 Rogue Wave Software, Inc. Thread Safety The Standard Library provided with this release is thread safe but not thread reentrant. Thread safe means that all library internal and global data is protected from simultaneous access by multiple threads. In this way, internal buffers as well as global data like cin and cout are protected during each individual library operation. Users, however, are responsible for protecting their own objects. According to the C++ standard, results of recursive initialization are undefined. To guarantee thread safety, the compiler inserts code to implement a spinlock if another thread is initializing local static data. If recursive initialization occurs, the code deadlocks even if threads are not used. 20 5.1 Enhancements and Changes, and Problems Corrected in Version 6.3 Enhancements, changes, and problems corrected are as follows: o To ensure thread safety, the basic_string reference count used to be protected by a mutex, which called thread locking and unlocking routines. Performance of this class in multithreaded applications has been improved by changing the implementation to use instead atomic builtins (see Appendix B in Using Compaq C++ for OpenVMS Alpha). [10.1138] o Undefined symbols from the Standard Library no longer occur when using the /names=as_is qualifier. [10.1158] o On OpenVMS Alpha Version 7.0 and above, the Standard Library headers now include pthread.h to implement multithread safety. Currently this has the side effect of polluting the global namespace with non-reserved macro and typedef names such as EXCEPTION, THROW, CATCH, and so on from . This problem has been acknowledged as a defect and is being investigated In the meantime, if you are using any of these names you must change them or devise a workaround. For example, if you have: #include #define CATCH 42 // trying to define your own macro, but get redefinition error you would need to make the following change: #include #undef CATCH // undef the pthread macro #include #define CATCH 42 // define your own macro [10.1205] o The string extraction operator no longer removes the extra space at the end of the string, as in the following example 21 ifstream inFile("input.dat"); // input.dat contains "abc de" inFile >> word; // read "abc" inFile.get(ch1); // ch1 should be space, was 'd' [10.1300] o The basic_string::find_first_not_of(charT, size_type) function now works correctly if the string contained embedded nulls. [10.1316] o In Version 6.2, basic_ostream::flush() did not always flush the buffer if the type of the stream was an fstream. The buffer is now always flushed. [10.1348] o Compiling a program in -std strict_ansi mode using the basic_fstream class no longer causes run-time seg faults or core dumps. [10.1357] o When using the Standard Library iostreams for interactive input to cin from a terminal, a user may have to type more than one Ctrl D to indicate end-of- file. [10.1413] o The iostreams and locales are now multi-thread safe. [10.1429] o Currently you might encounter compilation errors if you try to use a user-defined allocator and pointer class with the STL containers. This problem will be fixed in a future release. [10.1430] o The Standard Library vector class now allocates space correctly for elements greater than 1024 bytes; runtime core dumps caused by incorrect allocation in previous versions no longer occur. [10.1459] o The tree data structure, which sets and maps usage, has been refined to decrease the amount of space allocated for small element size containers. [10.1475] o The standard library headers no longer include pthread.h or tis.h. They can therefore be used in conjunction with the macro _PTHREAD_USE_D4 (DECthreads POSIX 1003.4a/Draft 4 (or d4) interface). [10.1540] 22 o The following functions have been added to basic_ filebuf class: bool __sync_with_device() const; // Returns the value of _RWsync_with_device flag. bool __sync_with_device(bool state); // Sets the value of _RWsync_with_device flag and returns // the previous value of the flag. These functions are not described in the C++ standard, and are provided as an extension in order to control the behaviour of basic_ostream::flush() method and std::endl and std::flush manipulators. The functions are available only on OpenVMS systems. If _RWsync_with_device flag is true, and if the type of the stream is an fstream, the basic_ostream::flush() function transfers all buffered data to the device as if the C Run-Time Library fsync() function were called. If _RWsync_with_device flag is false, it is not guaranteed that basic_ostream::flush() function or std::endl or std::flush manipulators will flush the data all the way to the device. To maintain compatibility with the behaviour of the Standard Library shipped with the Compaq C++ Version 6.2 compiler, the default value of _RWsync_with_device flag is false. The following example shows how the new functions are used. #ifndef __USE_STD_IOSTREAM #define __USE_STD_IOSTREAM #endif #include #include int main(void) { const char * filename = "file.dat"; std::ofstream testfile(filename); struct stat buf; // display file synchronization state 23 cout << "1? file synchronization state is: " << testfile.rdbuf()->__sync_with_device() << std::endl; // write a record to the file testfile << "x" << std::endl; // check file size. Expected zero because by default endl // manipulator does not force data to be transferred to // the device. stat(filename, &buf); cout << "file size is: " << buf.st_size << std::endl; // set _RWsync_with_device flag to TRUE and display // previous file synchronization state cout << "file synchronization state is: " << testfile.rdbuf()->__sync_with_device(1) << std::endl; // write another record to the file testfile << "y" << std::endl; // check file size. Expected four because now std::endl // will cause data to be transferred to the device. stat(filename, &buf); cout << "file size is: " << buf.st_size << std::endl; return 0; } [10.1574] 5.2 Enhancements and Changes, and Problems Corrected in Version 6.2A Enhancements, changes, and problems corrected are as follows: o Fix for raw_storage_iterator assignment operator In versions 6.2 and earlier, a problem in the assignment operator for the class raw_storage_iterator could cause a run-time seg fault if, for example, you called the algorithm stable_sort() more than once with the same container. The problem has been corrected. [10.1284] o Fix for basic_string::compare() member functions 24 In version 6.2, two of the basic_string::compare() member funrtions were throwing an exception if the length of the second string was longer than the length of the current string. This has been fixed so that they throw an exception only if the position the user specifies within the second string is greater than the length of the second string. [10.1298] o Fix for basic_string::resize() A problem in thebasic_string::resize() member function in Version 6.2 has been corrected. The incorrect behaveior was that if two strings pointed at the same underlying char*, and the resize() function was called on one of them, and if you then you changed the underlying string for one string, the value for the other strings value would also be changed. [10.1287] o Fix to string assignment operator when assigning string with embedded nulls A problem in the basic_string assignment operator prevented strings containing embedded nulls from being copied correctly. The problem has been corrected. [10.1238] 5.3 Enhancements and Changes in Version 6.2 The following enhancements and changes are included in Version 6.2: o Cleaner header file inclusion policy The new version of the Standard Library is much more effecient than previous versions in its header inclusion policy. For example, the header file no longer includes . and no longer include . Programs that used to count on these inclusions might break. You can correct them by explicitly including any header files you use in your own sources. o New interface to get_temporary_buffer and use_facet 25 Because the Version 6.2 C++ compiler now supports explicit template function arguments, it also supports the standard interface to the get_temporary_buffer() function. The following example shows how code must change: Change this: get_temporary_buffer(len,(T*)0); // two arguments to this: get_temporary_buffer(len); // one argument where "T" is the value type of the container. The standard interface to the locale class use_facet() function is also now supported. The following example shows how code must change: Change this: use_facet(loc,(ctype*)0); to this: // use_facet only takes one argument use_facet >(loc); o Smaller executables for users of the basic_string library component The Standard Library now provides a better separation of the STL and Standard IO components. As a result, users of the basic_string component of the Standard Library should obtain smaller executables. In Version 6.1, using only a string in an application caused all iostreamand locale object files from the Standard Library to be included in the executable. These unnecessary files are no longer included. A correction to the Standard Library helps programmers users of just the basic_string component to obtain smaller executables. In the previous version, using just a string in an application caused the iostream and locale object files from the Standard Library to be included in the executable. The new version corrects that problem. 26 5.4 Problems Corrected in Version 6.2 The following problems are corrected in Version 6.2: o money_get/money_put locale facets now conform to International C++ Standard The money_get and money_put locale facets have been corrected to match the standard. In the previous version, for example, money_get appeared as: template > class money_get; They now correctly match the standard, where the interface appears as: template > class money_get; Note that the second template argument "Intl" has been removed. The member functions get() and put() now accept Intl as an argument. o ios_base::openmode flags set to conform to the International Standard The Standard Library file stream classes have been corrected to conform to the International Standard with regard to setting the ios_base::openmode flags. In the previous release, it was possible to create a file for reading and writing with this code: #define __USE_STD_IOSTREAM #include #include int main() { fstream fs("foo.out", ios_base::in | ios_base::out); fs << "abc" << endl; return EXIT_SUCCESS; } 27 In the current release, this code works only if the file already exists. If the file does not exist, you must also specify ios_base::trunc; that is, you must change the first line in main() to: fstream fs("foo.out", ios_base::in | ios_base::out | ios_base::trunc); This conforms to table 92 in the Standard, which specifies the "C" equivalent of the File open modes. o Correction to list::sort(Compare) A bug in the list::sort(Compare comp) member function is corrected. Previously, if users supplied their own Comparison function object for the element of the list, the compiler issued a message stating that it required an operator< defined for the element type. This no longer occurs. o reverse_iterator now matches the Standard reverse_iterator has been changed to match the standard. It now takes only one template argument of type iterator instead of five. Users must change existing code to remove the additional unnecessary arguments. o bitset constructors no longer accept a const char A bitset can no longer be constructed with a const char* argument. For example, the following no longer compiles: bitset<32> b("111111111"); The constructor that takes a string is a templatized constructor, and thus can perform type deductions only on exact matches, not conversions (for example, const char* to string). To make the code in the previous example compile with the current version, the argument must be explicitly cast to a string, as follows: bitset<32> b( string("111111111")); o assign(size_t) removed from vector, deque, list 28 Previous releases of the Standard Library contained a member function called assign() inside the vector, deque, and list classes. This function accepted only a size_t argument. This has been removed, because it is not in the Standard. You must add an extra argument indicating the value you want assigned. For example, you change calls like the following: v.assign(5); // where v is a vector to: v.assign(5, int()); o allocator<>::deallocate(pointer) removed The member function allocator<>::deallocate(pointer) has been removed. The Standard requires two arguments for this member function. The second argument should be of size_type and have the same value as the first argument passed to allocator<>::allocate(). o basic_ios now initializes skipws|dec To conform to the Standard, the following basic_ ios constructor constructs a basic_ios object and initializes the format control bits to skipws | dec: explicit basic_ios(basic_streambuf*sb) Previously, this constructor also initialized the bit indicating that output is right justified. Because the constructor is called while constructing any of the IOStream objects cout, clog, cerr, wcout, wclog, or wcerr, the difference is apparent if you examine the format control bits set after initializing one of these objects. Consider the following program: 29 #include #include using namespace std; int main() { cout << cout.flags() << endl; cout << clog.flags() << endl; cout << cerr.flags() << endl; cout << wcout.flags() << endl; cout << wclog.flags() << endl; cout << wcerr.flags() << endl; return EXIT_SUCCESS; } The output now indicates that only the skipws and dec format control bits are initialized. Previously it would have indicated that the right bit was also set. o Some iterator classes removed The following classes no longer exist in the Standard and have been removed from library headers. reverse_bidirectional_iterator random_access_iterator bidirectional_iterator forward_iterator output_iterator input_iterator Use instead the template class iterator with the template argument category to indicate which type of iterator you are constructing. o The default allocator argument changed for basic_string The default allocator argument for the class basic_ string has been changed from allocator to allocator. Any STL container constructed with an allocator template argument no longer compiles, because the specialization of allocator does not contain all the necessary typedefs. o strstream now deletes underlying strstreambuf 30 A problem has been corrected in the Standard Library strstream classes that prevented underlying strstream- buf (and thus the string) from being deleted when the strstream object was destroyed. The standard states that they should be deleted if strmode & allocated is true and strmode & frozen is not true. For example: #define __USE_STD_IOSTREAM #include void func() { ostrstream myostr; myostr << "abc"; } If you called func() the string "abc" was never deleted when the myostr stream was destroyed. This problem has been corrected. Note that the Class Library strstream classes have always deleted the underlying string. o sync_with_stdio() function is static In previous versions, the function sync_with_stdio() was incorrectly declared as a member function of ios_ base. The function is now correctly defined as a static member function; it is no longer necessary to call it with the "->" or or "." notation. 5.5 Restrictions in Version 6.2 This section describes problems you might encounter when using the current release of the C++ Standard Library with the Compaq C++ compiler. Where appropriate, workarounds are suggested. o Do not use Standard Library template definition file names. The C++ Standard Library supplies the following template definition files in SYS$LIBRARY:CXXL$ANSI_ DEF.TLB: 31 algorithm.cfstream.cc streambuf.cvector.cc time.cc bitset.cc ios.cc locimpl.cc string.cc ctype.cc istream.cc numbrw.cc tree.cc collate.cc messages.cc complex.cc iterator.ccostream.cc valarray.ccmoney.cc deque.cc list.cc sstream.cc valimp.cc numeral.cc rwlocale.cc If you use the same prefix name for any of your local files and have the directory that contains them in your include search path, the automatic instantiation mechanism picks up your local copy and does not find the library files. (See Automatic Template Instantiation in Using Compaq C++ for OpenVMS Alpha.) It is best not to use any of these names as source file names for your application. o Redeclaration of Standard Library Functions Many of the prototypes in the Standard Library have been changed to conform to the C++ International Standard by the addition of exception specifications. This means that if you have redeclared the declarations in your own code, you need to add the correct exception specification in order to match what is declared in the header. For example: #include // override default operator new // this will give an error inline void* operator new(size_t s); To prevent this behavior, you must change your new() declaration to: inline void* operator new(size_t s) throw(bad_alloc); o Files/Macros for internal use only Compaq C++ Version 6.n ships the following non-Standard headers for Compaq internal use only. Their contents are subject to change and can not be relied on. 32 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,