Order of destruction for statically initialized objects

As of z/OS® V1R5 C++ compiler, you can use the LANGLVL(NOANSISINIT) option to maintain the order of destruction for statically initialized objects whenever you compile programs that had previously been compiled with z/OS V1R1 and earlier C++ compilers.

As of z/OS V1R2 C++ compiler, DLLs built by the compiler run object destructors differently from those created with the earlier C++ compilers.
Note: The compiler became fully compliant with the C++ 2003 standard as of z/OS V1R2 C++ compiler.
Table 1. Destruction of statically initialized objects and compliance with Standard C++
z/OS V1R1 and earlier C++ compilers z/OS V1R2 and later compilers
Destructor calls are run as the last thing on the atexit list, as part of the termination code. For objects created with the Standard C++ way of initializing (LANGLVL(ANSISINIT)):
  • Destructor calls for objects created by z/OS V1R2 and later compilers are added to the atexit list. This list will then be run before the atexit entry for the termination code.
  • Any DLL built with z/OS V1R2 and later compilers will have the destructors for the global objects run in the wrong order relative to other DLLs or main program that were built with z/OS V1R1 and earlier C++ compilers.