Compaq Pascal V5.7-81 for Tru64 UNIX Release Notes 25 May 1999 This document contains information about Compaq Pascal V5.7-81 including new features, and other topics. This file is of interest to both system management and application programmers. CONTENTS CHAPTER 1 COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.1 Overview Of Compaq Pascal . . . . . . . . . . . . 1-1 1.2 New Features In Compaq Pascal . . . . . . . . . . 1-1 1.2.1 Compaq Pascal Web Page . . . . . . . . . . . . . 1-2 1.2.2 Conditional Compilation And Other Directives . . 1-2 1.2.2.1 %IF . . . . . . . . . . . . . . . . . . . . . 1-3 1.2.2.2 %ERROR, %WARN, %INFO, And %MESSAGE . . . . . . 1-4 1.2.2.3 %DEFINED . . . . . . . . . . . . . . . . . . . 1-5 1.2.2.4 %ARCH_NAME . . . . . . . . . . . . . . . . . . 1-5 1.2.2.5 %COMPILER_VERSION . . . . . . . . . . . . . . 1-6 1.2.2.6 %DATE And %TIME . . . . . . . . . . . . . . . 1-6 1.2.2.7 %FILE . . . . . . . . . . . . . . . . . . . . 1-6 1.2.2.8 %IDENT . . . . . . . . . . . . . . . . . . . . 1-6 1.2.2.9 %LINE . . . . . . . . . . . . . . . . . . . . 1-6 1.2.2.10 %MODULE . . . . . . . . . . . . . . . . . . . 1-6 1.2.2.11 %ROUTINE . . . . . . . . . . . . . . . . . . . 1-6 1.2.2.12 %SYSTEM_NAME . . . . . . . . . . . . . . . . . 1-7 1.2.2.13 %SYSTEM_VERSION . . . . . . . . . . . . . . . 1-7 1.2.3 Enhanced -I Option For Default Pathnames . . . . 1-7 1.2.4 New -constant Option For Defining Constants . . 1-8 1.2.5 New "NOT IN" Binary Set Operator . . . . . . . . 1-8 1.2.6 -assume accuracy_sensitive Command Line Option . 1-9 1.2.7 -usage nongrnacc Command Line Option . . . . . . 1-9 1.2.8 -usage uncallable Command Line Option . . . . 1-10 1.2.9 UNDEFINED Predeclared Routine . . . . . . . . 1-10 1.2.10 Enhanced Optimization And Code Generation . . 1-10 1.3 Compaq Pascal Run-Time Library . . . . . . . . . 1-11 1.3.1 Run-Time Library Now Thread-safe . . . . . . . 1-11 1.3.2 Compaq Pascal Run-Time Library And The QUADRUPLE Datatype . . . . . . . . . . . . . . 1-11 1.4 Known Problems And Restrictions . . . . . . . . 1-11 1.5 Documentation Errors . . . . . . . . . . . . . . 1-14 1.5.1 Updating The Whatis Database . . . . . . . . . 1-15 1.5.2 Use Of [ENVIRONMENT] Attribute Without A Filename . . . . . . . . . . . . . . . . . . . 1-15 1.5.3 UNSIGNED8 And UNSIGNED16 Predeclared Subranges 1-16 1.5.4 Optimize Attribute Corrections . . . . . . . . 1-16 1.5.5 Support For C_STR_T Predefined Type On OpenVMS VAX Systems . . . . . . . . . . . . . . . . . 1-18 1.6 Compiling For Optimal Performance . . . . . . . 1-18 1.7 Compaq Pascal Run-Time Library Support Routines 1-19 1.8 Exception Handling On Tru64 UNIX . . . . . . . . 1-19 1.9 Migrating Compaq Pascal Programs . . . . . . . . 1-19 1.9.1 Migrating From RISC ULTRIX Systems To Tru64 UNIX Systems . . . . . . . . . . . . . . . . . 1-19 1.9.2 Migrating From OpenVMS Systems To Tru64 UNIX . 1-22 1.9.2.1 Sharing Environment Files Across Platforms . 1-22 1.9.2.2 Default Size For Enumerated Types And Booleans . . . . . . . . . . . . . . . . . . 1-22 1.9.2.3 Default Data Layout For Unpacked Arrays And Records . . . . . . . . . . . . . . . . . . 1-22 1.9.2.4 IADDRESS And VOLATILE . . . . . . . . . . . 1-23 1.9.2.5 INT On Large Unsigned Numbers Now Overflows 1-23 1.9.2.6 Bound Procedure Values . . . . . . . . . . . 1-24 1.9.2.7 Argument List Functions . . . . . . . . . . 1-24 1.9.2.8 %DICTIONARY Directive . . . . . . . . . . . 1-24 1.9.2.9 VAX Floating Datatypes . . . . . . . . . . . 1-24 1.9.2.10 Relative And Indexed Files . . . . . . . . . 1-24 1.9.3 Calling C Routines From Pascal . . . . . . . . 1-25 1.10 Problems Corrected Since Last Release Of Compaq Pascal . . . . . . . . . . . . . . . . . . . . . 1-26 CHAPTER 1 COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.1 Overview Of Compaq Pascal Compaq Pascal V5 is a major release of the Compaq Pascal language. The major new features of Compaq Pascal V5 are: 1. New platform support. Compaq Pascal now supports OpenVMS Alpha and Tru64 UNIX (formerly known as Digital UNIX) systems as well as continued support for OpenVMS VAX systems. 2. New functionality to be more compatible with UNIX -based Pascals (ie, Pascal for RISC on the RISC/ULTRIX platforms). 3. New functionality to efficiently use the Alpha architecture from Compaq Pascal. Compaq Pascal V5.7-81 requires Digital UNIX V4.0B or later. 1.2 New Features In Compaq Pascal Since the release of V5.6, Compaq Pascal for Tru64 UNIX systems contain: 1. A Conditional Compilation system 2. New directives for obtaining compile-time information 3. Enhanced -I option for providing default path information for %INCLUDE directives and inherit attributes 4. New -constant option for defining a limited set of Pascal constants from the command line. 5. Bug fixes COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 6. Command line option for assuming floating point accuracy of program 7. New -usage keyword for supressing messages about byte-granular code 8. New -usage keyword for supressing messages about uncallable routines 9. The UNDEFINED builtin routine has been implemented 10. A new "NOT IN" binary operator to test if an element is not in a set 11. Enhanced optimization and code generation 1.2.1 Compaq Pascal Web Page You can find the Compaq Pascal home page at http://www.openvms.digital.com/commercial/pascal/pascal_index.html Please visit the web site and register with us via the "Pascal Feedback" button. By registering with us, we can send out updates on future Compaq Pascal releases as well as getting your feedback on Compaq Pascal features and future directions. 1.2.2 Conditional Compilation And Other Directives Based on many customer requests, we have added syntax for conditional compilation to the Compaq Pascal compiler. On Tru64 UNIX, Compaq Pascal currently supports the C preprocessor in the driver by preprocessing the Pascal source before passing it to the compiler. That support remains present and will not change. The new syntax added to the compiler is different from the C preprocessor for several reasons. First, we felt we could not exactly duplicate the C preprocessor in the compiler on OpenVMS systems. Having a syntax that looked the same, but functioned differently between OpenVMS and Digital UNIX systems was undesirable. Second, we wanted the conditional compilation directives to have access to names and functions in the Pascal compiler to make it more powerful. All of the new directives can appear in any column and do not have to be on a line by themselves. The preprocessor is "token" based, not line based. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.2.2.1 %IF The %IF preprocessing directive has the following syntax: %IF compile-time-expression %THEN Pascal tokens... [%ELIF compile-time-expression %THEN Pascal tokens...]... [%ELSE Pascal tokens...] %ENDIF As shown by the syntax, a %IF directive can have zero or more %ELIF parts and zero or one %ELSE parts. %IFs can be nested upto 32 deep. Note that skipped sections must still be valid Compaq Pascal tokens. The skipped tokens are not processed semantically by the compiler. For example, 1) CONST Debug_Flag := true; { or false } VAR I : integer; I := %IF Debug_Flag %THEN 1 %ELSE 0 %ENDIF; %IF Debug_Flag %THEN writeln('Debug: the value of I is ',i:1); %ENDIF 2) TYPE Configs = (Config1, Config2, Config3); CONST Config = Config1; { or Config2 or Config3 } %IF Config = Config1 %THEN { Code for Config1... } %ELIF Config = Config2 %THEN { Code for Config2... } %ELSE Config = Config3 { Code for Config3...} %ENDIF COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES Notice that the compile-time expression for the %IF statement is the same compile-time expression that can be used anywhere else in Compaq Pascal. You can any operator or builtin routine in a %IF control expression as you can in any constant expression. One use of %IF is to compile for various configurations or environments (as shown in the above example). Instead of defining a constant in the Pascal source, it is reasonable to want to define the constant from the command line. See the description of the -constant command line option later in the release notes. Since the pc driver runs the C-preprocessor over the program before invoking the compiler, you can also use the -Dname=def command line option to help you create the appropriate Compaq Pascal constants for subsequent %IF directives to use. For example, you can include the following constant definition in your code const Config = _config_name_; and use the following pc command line to pick a configuration. $ pc -D_config_name_=Config1 test.pas After the C-preprocessor is run over the input file, the constant definition will be const Config = Config1; then subsequent %IF directives can test the value of config. 1.2.2.2 %ERROR, %WARN, %INFO, And %MESSAGE These directives accept a list of compile-time string expressions and produce either a compile-time error, compile-time warning, compile-time informational, or terminal-only output, respectively. The syntax is: %ERROR ( string-expression,... ) %WARN ( string-expression,... ) %INFO ( string-expression,... ) %MESSAGE ( string-expression,... ) For example, COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1) TYPE Some_Type = ... ; %IF SIZE(Some_Type) > 8 %THEN %ERROR ('We do not handle types that large') %ENDIF 2) %IF DEBUG_MODE %THEN %MESSAGE ('Debug-mode is enabled') %ENDIF 3) %IF Config = Config1 %THEN { Code for Config1... } %ELIF (Config = Config2) or (Config = Config3) %THEN { Code for Config2/Config3... } %ELSE %WARN ('Config not supported, defaulting to generic') { Code for generic config... } %ENDIF 1.2.2.3 %DEFINED The %DEFINED directive takes a name and returns TRUE if the name has a meaning in the current scope; otherwise it returns FALSE. For example, %IF %DEFINED(X) %THEN writeln(x); %ENDIF 1.2.2.4 %ARCH_NAME %ARCH_NAME returns either 'VAX' or 'Alpha' depending on the architecture of the system performing the compilation. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.2.2.5 %COMPILER_VERSION %COMPILER_VERSION returns a string containing the version string of the Compaq Pascal compiler performing the compilation. 1.2.2.6 %DATE And %TIME %DATE returns a string containing the date at the beginning point of the compilation. %TIME returns a string containing the time at the beginning point of the compilation. 1.2.2.7 %FILE %FILE returns a string containing the filename that is current being compiled. On OpenVMS, the string contains a full OpenVMS file specifications including the disk, directory, filename, filetype, and version fields. On Tru64 UNIX, the string contains just the filename and filetype. 1.2.2.8 %IDENT %IDENT returns a string containing the compilation's ident string that is set with the [IDENT()] attribute. 1.2.2.9 %LINE %LINE returns an integer denoting the current line number in the source file. 1.2.2.10 %MODULE %MODULE returns a string with the name of the module/program being compiled. 1.2.2.11 %ROUTINE %ROUTINE returns a string with the name of the current routine being compiled. If used in the executable portion of a PROGRAM, the COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES program's name is returned. If used in the declaration section of a MODULE/PROGRAM, the module's/program's name is returned, respectively. 1.2.2.12 %SYSTEM_NAME %SYSTEM_NAME returns either 'OpenVMS' or 'DigitalUNIX'. Note that the embedded space in 'Digital UNIX' has been removed so you could do some limited conditionalization with: %include 'foo'+%system_name+'.dat' The %SYSTEM_NAME directive will not be modified to return 'Tru64UNIX' since that may affect existing applications. 1.2.2.13 %SYSTEM_VERSION %SYSTEM_VERSION returns a string containing system-specific information on the system performing the compilation. On OpenVMS, %SYSTEM_VERSION returns the value of SYI$_VERSION from the $GETSYI system-service. On Tru64 UNIX, %SYSTEM_VERSION returns the concatenation of the fields of the utsname structure (/usr/include/sys/utsname.h) from a call to uname(). 1.2.3 Enhanced -I Option For Default Pathnames The -I option on the pc command has been enhanced to specify default path names for %INCLUDE directives and [INHERIT] attributes that specify filenames that do not begin with a "/". The compiler applies the -I information to the following Pascal constructs: %INCLUDE 'name' or %INCLUDE 'name.ext' [INHERIT('name')] or [INHERIT('name.ext')] In previous compilers, the filename was used with only a default file extension. If the file wasn't found in the current directory, an error was issued. Now, the compiler searches: 1. the current directory with a default extension of '.pas' for %INCLUDE directives and '.pen' for [INHERIT] attributes (just like before); COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 2. any directories specified with -I (in the order specified) with the appropriate default extension; 3. /usr/include with the appropriate default extension. 1.2.4 New -constant Option For Defining Constants A new -constant option has been added to allow a limited set of Pascal constants to be defined from the command line. This capability was designed to be used with the conditional-compilation facility, but can be used in any situation where defining constants from the command line might be useful. The syntax is -constant name=value where 'name' is the name of a Pascal constant to create. You cannot redefine any predeclared Pascal name via the command line. The 'value' can be one of the following: 1. integer-literal 2. - integer-literal 3. TRUE 4. FALSE 5. "string-literal" 6. 'string-literal' Non-base-10 integer literals are not currently supported via the command line. For example, $ pc -constant debug=true -constant maxsize=10 -constant ident="V1.0" 1.2.5 New "NOT IN" Binary Set Operator A new binary operator, NOT IN, has been added as an extension to compliment the existing IN operator. The NOT IN operator is defined to return TRUE if the element specified by the left operator is not an element of the set specified by the right operator; otherwise it COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES returns FALSE. The following two expresions are identical. A NOT IN B NOT (A IN B) The new operator allows expressios that are easier to understand and reduces the number of parentheses that are needed. 1.2.6 -assume accuracy_sensitive Command Line Option The -assume accuracy_sensitive command line option specifies whether certain code transformations that affect floating-point operations are allowed. These changes may or may affect the accuracy of the program's results. If you specify noaccuracy_sensitive, the compiler is free to reorder floating-point operations based on algebraic identities (inverses, associativity, and distribution). This allows the compiler to move additional floating-point operations outside of loops or reduce or remove floating-point operations totally, thereby improving performance. The default, accuracy_sensitive, directs the compiler to avoid certain floating-point trasformations that might slighly affect the program's accuracy. In previous versions of Compaq Pascal on Tru64 UNIX systems, the compiler defaulted to noaccuracy_sensitive, which resulted in some programs getting unexpected results. These transformations are now disabled by default and you must explicitly request them. 1.2.7 -usage nongrnacc Command Line Option The -usage nongrnacc command line option specifies whether the compiler should issue warning messages for code sequences that it cannot guarantee to match your granularity requestion from the -granularity option. When the compiler cannot guarantee that the generated code matches the granularity setting, it will issue a warning message. You should examine your program to make sure that the variable being accessed is quadword aligned and is a multiple of quadwords in size. In that case, the resulting code will be correct even if the compiler couldn't determine that at compile-time. Such cases involve pointer dereferences or VAR parameters. These messages are enabled by default. They have been generated by the compiler for the last several releases. This new keyword allows COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES you to suppress the messages if you so choose. You suppress the messages with the -usage nonongrnacc option. 1.2.8 -usage uncallable Command Line Option The -usage uncallable command line option specifies whether the compiler should issue informational messages for routines that are declared but never called. These messages are disabled by default. In previous releases, the -usage unused command line option suppressed messages about unused variables and uncalled routines. With the new keyword, the catagories have been separated. 1.2.9 UNDEFINED Predeclared Routine The UNDEFINED predeclared routine has been implemented for both OpenVMS Alpha and Tru64 UNIX. The UNDEFINED routine returns FALSE if the floating-point value is finite (as defined by the Alpha Architecture definition) and returns TRUE if it is not finite. An Alpha finite number is a floating-point value with a definite, in-range value. Specifically, all numbers in the inclusive ranges -MAX through -MIN, zero, and +MIN through +MAX, where MAX is the largest non-infinite representable floating-point number for the variable's type and MIN is the smallest non-zero representable normalized floating-point number for the variable's type. These correspond to the MINREAL, MAXREAL, MINDOUBLE, MAXDOUBLE, MINQUADRUPLE, and MAXQUADRULE predeclared constants. For F_Float, D_Float, and G_Float, finites do not include reserved operands and dirty zeros (this differs from the VAX interpretation of dirty zeros as finite). For S_Float, T_Float, and X_Float, finites do not include infinites, NaNs, or denormals, but do include minus zero. 1.2.10 Enhanced Optimization And Code Generation Compaq Pascal contains a newer version of the GEM code generator that includes better optimizations and code generation. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.3 Compaq Pascal Run-Time Library 1.3.1 Run-Time Library Now Thread-safe The Compaq Pascal Run-Time Library has been enhanced to work properly with DECthreads. To install the RTL on another system, just install the DPOxxx kit on the systems and chose the RTL subset. The thread-safe support has been merged into the RTL bundled on the base CDROM in Digital UNIX V4.0. The thread support was introduced in DPORTL541. 1.3.2 Compaq Pascal Run-Time Library And The QUADRUPLE Datatype The run-time library has been enhanced to include entry points for reading and writing QUADRUPLE values. If you plan to move applications that use QUADRUPLEs to other systems, you need to make sure that the RTL on those system contains the QUADRUPLE support. To do this, just install the DPOxxx kit on the systems and chose the RTL subset. The QUADRUPLE support has been merged into the RTL bundled on the base CDROM in Digital UNIX V4.0. The QUADRUPLE support was introduced in DPORTL540. 1.4 Known Problems And Restrictions Here is a list of language features that are not yet implemented or do not work as documented in Compaq Pascal for Tru64 UNIX. 1. Using Discriminated Schema as Formal Discriminant Types Extended Pascal allows a discriminated ordinal schema type to be subsequently used as the type of a formal schema discriminant. For example, TYPE SUBR(L,U:INTEGER) = L..U; DSUBR = SUBR(expression,expression); SCH1(D:DSUBR) = ARRAY [1..D] OF INTEGER; SCH2(D:DSUBR) = RECORD CASE D OF 1: (F1:INTEGER); 2: (F2:CHAR); END; Compaq Pascal does not currently support this construct. 2. Files with Schema Components Extended Pascal allows file components to contain schematic items and therefore provide run-time sized file components. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES For example, TYPE SUBR(L,U:INTEGER) = L..U; FILE_COMP = ARRAY [SUBR(expr,expr)] OF INTEGER; VAR F : FILE OF FILE_COMP; Compaq Pascal does not currently support this feature and requires that the component sizes of files be known at compile-time. 3. Using Formal Discriminants Inside Initial State Specifiers Extended Pascal allows the formal discriminant to appear in an initial state specifier in the schema definition. For example, TYPE R(D:INTEGER) = RECORD F1 : INTEGER VALUE D; END; A(D:INTEGER) = ARRAY [1..D] OF INTEGER VALUE [OTHERWISE D]; Compaq Pascal does not currently support this feature and requires that all initial state values be compile-time expressions. 4. Changing Variants When Selector Is A Discriminant If a formal discriminant is used as a variant tag, it is illegal to change the variant once the variable has been created. For example, TYPE R(D:INTEGER) = RECORD CASE D OF 1: (ONE : INTEGER); 2: (TWO : INTEGER); OTHERWISE (OTHERS : BOOLEAN); END; VAR V : R(1); BEGIN V.TWO := 2; { Is illegal since it changes variants from 1 to 2 } END; Compaq Pascal does not currently generate run-time checking code to detect this violation. 5. The AND_THEN and OR_ELSE Boolean operators do not short-circuit when used in constant expressions. All constant expressions currently do full evaluation in a left-to-right order. For example, COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES CONST X = FALSE AND_THEN (1 DIV 0 = 0); This example will currently generate a compilation error instead of correctly definiting the constant X to be the value FALSE. 6. The Compaq Pascal compiler currently allows you to use the SIZE function on TIMESTAMP variables. As in the case for file variables, these types are abstract objects and the compiler should not permit assumptions about their size to be used. 7. When the buffer variable of a file is passed as a VAR parameter, the allocation size of the formal VAR parameter must match that of the components of the file. Failure to do so will result in an Internal Compiler Error. For example: PROGRAM A; VAR F : PACKED FILE OF 0..65535; G : FILE OF [WORD] 0..65535; PROCEDURE P( VAR I : INTEGER ); EXTERNAL; BEGIN P(F^); { causes an Internal Compiler Error } P(G^); { causes an Internal Compiler Error } END. 8. The standard file variable ERR is not yet supported. 9. The MESSAGE builtin is not yet supported. 10. Jumping into a WITH statement with a GOTO statement may result in an Internal Compiler Error if compiled with /OPTIMIZE. Such programs are illegal in nature as bypassing the prologue of the WITH statement skips around the code that precomputes the address of the record used in the WITH statement. 11. The ALIGNED attribute only allows upto 8192 byte boundaries at present (ie, ALIGNED(13)). Support for larger alignments will be provided in a future release. 12. Incomplete support for INTEGER64/UNSIGNED64; Currently, the following uses of the INTEGER64/UNSIGNED64 datatypes are unsupported: a) Literals requiring more than 32-bits cannot be used in the declaration section. This implies that you cannot write such things as: COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES CONST BigNum = 12345678912345678; but you CAN write things such as: i64 := 12345678912345678; b) INTEGER64/UNSIGNED64 expressions cannot be used as case selectors or variant record tags. c) Subranges requiring more than 32-bits cannot be declared (since you cannot specify literals large enough to construct them). d) Array index types cannot be INTEGER64/UNSIGNED64 (since you cannot specify subranges of them). e) Certain builtin routines do not yet support INTEGER64/UNSIGNED64 items (such as LOWER, UPPER, MIN, and MAX). f) The predeclared constants MAXINT64 and MAXUNSIGNED64 are not present. g) INTEGER64/UNSIGNED64 types cannot be used in variable typecasts. 13. The compiler does not automatically close local files when the declaring routine returns. This will be fixed in a future release. 14. The compiler does not support debug information for the following data/variable types: a) Schematic variables (except the predefined type STRING) b) Conformant varying parameters c) Conformant parameters We will try to provide better debug information for these data types in a future release of Compaq Pascal if possible. 1.5 Documentation Errors COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.5.1 Updating The Whatis Database The Compaq Pascal for Tru64 UNIX Systems Installation Guide omitted instructions on how to update the /usr/share/man/whatis database used with the whatis(1) command. After installation of the Compaq Pascal documentation subset (DPOMANnnn), invoke the catman(1) program from the root account with the -w flag. For example, # catman -w 1.5.2 Use Of [ENVIRONMENT] Attribute Without A Filename In the Compaq Pascal User Manual for Tru64 UNIX Systems, the behavior of the compiler when the [ENVIRONMENT] attribute is used without a filename is described incorrectly. If you do not specify a filename with the [ENVIRONMENT] attribute, then the filename of the source file is used with a ".pen" extension for the name of the environment file. For example, { Module share_data.pas } [ENVIRONMENT] Module Share_Data; CONST Rate_For_Q1 = 0.1211; Rate_For_Q2 = 0.1156; END. The above module, when compiled, would result in the creation of an environment file named "share_data.pen". If a filename is specified with the [ENVIRONMENT] attribute, then that filename is used as-is in creating the environment file. The [INHERIT] attribute will cause the compiler to first attempt to open a file with the exact filename that is supplied. If this fails, an extension of ".pen" is added to the filename specified and the open is retried. For example, { Program inherit_example.pas } [INHERIT ('share_data')] COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES Program inherit_example(output); CONST My_Rate = Rate_For_Q1*2.0; BEGIN Writeln(My_Rate) END. When the program above is compiled, the compiler first attempts to open the file 'share_data' as an environment file. If 'share_data' is not found the compiler attempts to open 'share_data.pen' as an environment file. If 'share_data.pen' is not found an error message is issued and the compilation is stopped. 1.5.3 UNSIGNED8 And UNSIGNED16 Predeclared Subranges The UNSIGNED8 and UNSIGNED16 predeclared subrange types are documented as being subranges of UNSIGNED. However, they are actually subranges of INTEGER with positive values that correspond to an UNSIGNED subrange of the same size. This subtle distinction in the definition is almost impossible to detect from a program and shouldn't be a problem in the general case. 1.5.4 Optimize Attribute Corrections Due to a problem in the compiler, optimization occurred when the /NOOPT qualifier was used and a form of the OPTIMIZE([NO]INLINE) attribute was used. This problem has been corrected. The use of the OPTIMIZE([NO]INLINE) attribute only controls whether inlining is enabled, not whether other code optimizations are enabled. The Compaq Pascal Language Reference Manual section describing the OPTIMIZE attribute has been expanded to more fully describe the interaction between the OPTIMIZE attribute and the /OPTIMIZE qualifier. Here is that updated text: OPTIMIZE -------- The OPTIMIZE attribute specifies optimization options that are to be enabled during compilation of a compilation unit or routine. OPTIMIZE [[( {identifier},... )]] The options listed with the OPTIMIZE attribute are enabled. The negation of an option disables that optimization. The valid options are ALL, NONE, INLINE, NOINLINE. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES Attribute Action ---------------------------- ----------------------------------- [OPTIMIZE], [OPTIMIZE(ALL)] Enables all optimization components. Inline expansion of user-defined routines is enabled in automatic selection mode. [OPTIMIZE(NOINLINE)] Disables inline expansion for user defined routines. All other optimization components are enabled/disabled according to command line or the setting of the OPTIMIZE attribute on an enclosing scope routine. [OPTIMIZE(INLINE)] Enables preferential inline expansion of user-defined routines. All other optimization components are enabled/disabled according to command line or the setting of the OPTIMIZE attribute on an enclosing scope routine. [OPTIMIZE(ALL,NOINLINE]) Enables all optimization components, disables inline expansion for user defined routines. [OPTIMIZE(NONE,INLINE)] Disables all optimization components, enables inline expansion of user-defined routines. [NOOPTIMIZE],[OPTIMIZE(NONE)] Disables all optimization components, disables inline exapsnion of user-defined routines. Usage and Default Information ----------------------------- o This attribute can be applied to routines and compilation units. o Optimization features specified with the OPTIMIZE attribute override command line settings and settings inherited from outer scopes. o The INLINE option specifies that a routine should be inlined preferentially, regardless of the results of heuristics which are normally used to automatically determine if a routine is to be inlined. There are still cases where a routine that is marked as INLINE preferred will not be inline expanded, such as routines that have formal parameters of non-static types, or that declare or access non-static types. o If no OPTIMIZE attribute is specified for a routine in a nested scope, the OPTIMIZE attribute settings from the enclosing routine are used. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES o If the OPTIMIZE attribute is used on a routine on OpenVMS Alpha or Tru64 UNIX systems, only the INLINE and NOINLINE keywords are processed. The other forms of the OPTIMIZE attribute are parsed but perform no function. You cannot modify the optimization settings of individual routines on these systems. Usage and Default Information on OpenVMS systems only: ------------------------------------------------------ o On OpenVMS VAX systems, if an explicit OPTIMIZE(INLINE) attribute exists on a routine declaration, the compiler checks for anything that prohibits inline expansion of the routine, such as it being an external routine. However, the compiler does not check the call environment, such as the size of the calling and called routine. Instead, if it is legal to expand the routine, it always expands the code, regardless of the call environment. This gives you more control over the decision to inline a routine. o On OpenVMS VAX systems, Compaq Pascal does not inline routines that have formal parameters of nonstatic types, or that declare or access objects of nonstatic types. 1.5.5 Support For C_STR_T Predefined Type On OpenVMS VAX Systems Section 2.7 of the Compaq Pascal Reference Manual states that the C_STR_T predefined type is not available on OpenVMS VAX systems. That statement is not true anymore. Support for the C_STR_T type was added to Compaq Pascal for OpenVMS VAX Systems after the manual was revised. This will be corrected in a future revision of the documentation. 1.6 Compiling For Optimal Performance The following command line will result in producing the fastest code from the compiler. pc -nozero_heap -math_library fast -O5 -arch host You may also want to use the new performance flagger ( -usage performance) to identify datatypes that could be modified for additional performance. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.7 Compaq Pascal Run-Time Library Support Routines The following routine has been added to libpas.a/libpas.so to enable a program to determine the C file variable that is used to implement a Pascal file variable. The routine is: function pas$c_file_variable( var f : text ) : pointer; external; This routine will return the address of the C file variable used to implement the specified Pascal file variable. The file must already be opened before the routine can be called. 1.8 Exception Handling On Tru64 UNIX To support the ESTABLISH and REVERT builtins, non-local GOTOs, and to signal and print run-time error messages, the Compaq Pascal run-time library (libpas) uses the stack-based exception handling mechanism. See "man exception_intro" for more information. At the beginning of any program that uses the Pascal run-time library, the library does the following: 1. Registers the EXC_Raise_Signal_Exception routine as a signal handler for the SIGTRAP and SIGFPE signals using sigaction(). 2. Registers a private last-chance handler with EXC_Set_Last_Chance_Handler(). If your program registers its own signal handlers for SIGTRAP or SIGFPE; or registers a different last-chance handler, then errors signalled at run-time may not produce the expected run-time messages and language handlers may not be called to handle the error. Other language features, such as non-local GOTOs, should continue to work as expected. In addition, the special last-chance handler is only used when the main program is not written in Pascal. 1.9 Migrating Compaq Pascal Programs 1.9.1 Migrating From RISC ULTRIX Systems To Tru64 UNIX Systems For users who are migrating from Pascal for RISC on the RISC/ULTRIX DECstations, the new features are all those features from the VAX Pascal product that don't exist in Pascal for RISC. The list is too long to include here. However, it includes run-time sized types and variables, a true separate compilation mechanism, variable length COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES strings, compiler attributes (aka pragmas), etc. See the Compaq Pascal documentation for more information. 1. Pascal for RISC and Compaq Pascal implement different Pascal language features. The following list enumerates differences you will see when compiling a Pascal program written for Pascal for RISC using Compaq Pascal for Tru64 UNIX Systems. a) The Pascal for RISC independent compilation feature is not supported in Compaq Pascal. Compaq Pascal provides independent compilation via environment files, see the Compaq Pascal Language Reference Manual for more information. b) The Pascal for RISC NULL statement is not supported in Compaq Pascal. c) The Pascal for RISC syntax for modifying the default alignment rules for record fields is not supported in Compaq Pascal. Compaq Pascal provides the POS and ALIGNED attributes to implement this feature. See the Compaq Pascal Language Reference Manual for more information on the POS and ALIGNED attributes. d) The default integer size can be changed to 16 bits using the Pascal for RISC option "-apc". The default integer size cannot be changed in Compaq Pascal. e) The Pascal for RISC type conversion routines ALFA, BOOLEAN, CHAR, CARDINAL, DOUBLE, INTEGER, INTEGER16, INTEGER32, and REAL are not provided by Compaq Pascal. f) The maximum length of identifiers in Pascal for RISC is 32 characters, in Compaq Pascal identifiers can be up to 31 characters in length. g) Pascal for RISC allows certain negative numbers in SETs. Compaq Pascal only allows positive numbers in SETs. h) Pascal for RISC allows up to 512 items in an INTEGER or CARDINAL SET. Compaq Pascal only allows up to 255 elements in an INTEGER or UNSIGNED SET. i) Pascal for RISC writes the value of enumerated types in lower case. Compaq Pascal writes them in upper case. j) Pascal for RISC has different default field widths than Compaq Pascal. k) Pascal for RISC defines the type CHAR as being the subrange 0..127 when used as a base-type. Compaq Pascal allows the full subrange 0..255 when CHAR is used as a COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES base-type. l) Pascal for RISC and Compaq Pascal may flag different variables and routines as uninitialized and unused since different algorithms are used by the two compilers to ascertain this information. m) The Pascal for RISC definition and syntax for type-casting is different from the Compaq Pascal definition for type-casting. See the Compaq Pascal Language Reference Manual for more information in type-casting in Compaq Pascal. n) The Pascal for RISC command options -w, -stdiso, -stdansi, are provided by the Compaq Pascal options -nowarn, -std ansi, and -std iso. o) The Pascal for RISC command option -casesense is not supported. Mixed case names are provided by Compaq Pascal attributes on routine and variable names. p) The Pascal for RISC command options -j, -EB, -EL, -H_c, -#, -W_c, -t, -B, -h, -ko , -k, -S, -Olimit are not supported by Compaq Pascal. 2. There are behavioral and implementation differences between Pascal for RISC and Compaq Pascal. The following list enumerates the differences you might see at run-time when running code compiled by Compaq Pascal for Tru64 UNIX Systems. a) Pascal for RISC always short-circuits the AND and OR boolean operators. Compaq Pascal only guarantees short-circuiting for the AND_THEN and OR_ELSE boolean operators. b) Pascal for RISC determines REAL vs. DOUBLE precision constants based on their use. Compaq Pascal provides a mechanism for specifying constants that are DOUBLE precision, see the Compaq Pascal Language Reference Manual for more details. By default, all floating constants are of type REAL in Compaq Pascal. c) Pascal for RISC uses a "non-zero" value for the ordinal value of TRUE. Compaq Pascal will only store a 1 into boolean variables for a TRUE value. Non-Pascal code passing boolean arguments to Compaq Pascal could notice behavior differences if even numbers (2,4,6...) were placed into boolean variables to signify TRUE, Compaq Pascal will treat even values as FALSE since the low order bit is not set. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES d) Pascal for RISC supports the STLIMIT procedure. Compaq Pascal will recognize STLIMIT but will not count executed statements or generate a run-time error when STLIMIT is called. e) Pascal for RISC trims trailing blanks from strings when printed with a field width of 0. Compaq Pascal follows the Pascal standard, which dictates that strings printed with a field width of 0 print no characters. f) Pascal for RISC left justifies output when negative field widths are used. Compaq Pascal treats negative field widths as runtime errors. 1.9.2 Migrating From OpenVMS Systems To Tru64 UNIX The following sections describe issues which affect Compaq Pascal programs being moved from OpenVMS systems to Tru64 UNIX. 1.9.2.1 Sharing Environment Files Across Platforms The compiler will only inherit environment files created from a compiler for the same target platform. For example, you cannot inherit environment files generated on an OpenVMS VAX system with the Compaq Pascal for Tru64 UNIX compiler. 1.9.2.2 Default Size For Enumerated Types And Booleans The default size for enumerations and Booleans in unpacked structures is longword on Tru64 UNIX. On OpenVMS VAX systems, the default is a byte for Booleans and small enumerations or word for larger enumerations. If you need the OpenVMS VAX behavior on Digtal UNIX systems, you can use the -enumeration_size byte command qualifier, the [ENUMERATION_SIZE(BYTE)] attribute, or you can place individual [BYTE] or [WORD] attributes on the affected fields or components. The default for OpenVMS VAX compilers will remain /ENUMERATION_SIZE=BYTE for compatibility. 1.9.2.3 Default Data Layout For Unpacked Arrays And Records On Tru64 UNIX and OpenVMS Alpha systems, the default data layout is "natural" alignment. This means that record fields and array COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES components are aligned on boundaries based on their size. For example, INTEGERs on longword boundaries, INTEGER64s on quadword boundaries, etc. On OpenVMS VAX systems, the default alignment rule is to allocate such fields on the next byte boundary. If you need the OpenVMS VAX behavior on Tru64 UNIX, you can use the -align vax command qualifier or the [ALIGN(VAX)] attribute. 1.9.2.4 IADDRESS And VOLATILE The IADDRESS builtin assumes that its parameter is a VOLATILE variable, a VOLATILE parmeter, or a routine entry point. Unlike the ADDRESS builtin, the IADDRESS builtin does not issue a warning if the parameter does not have the VOLATILE attribute. On OpenVMS VAX systems, the Compaq Pascal compiler would often allocate variables in such a way that they existed for the entire routine in which they were declared. In these situations, using the IADDRESS builtin to obtain the address of the variable worked as expected. Usually, the address was passed to a system service via an item list or something similar. On Tru64 UNIX, the Compaq Pascal compiler is much more agressive with optimizating data layout on the stack. In the absence of a VOLATILE attribute, the compiler will allocate variables for the smallest possible duration. If the address is taken with IADDRESS, by the time the address is written into by a library routine, the variable may nolonger exist and the memory store would corrupt another variable. In summary, if the IADDRESS builtin is used on automatic variables or parameters, then the VOLATILE attribute must be used to ensure proper behavior. 1.9.2.5 INT On Large Unsigned Numbers Now Overflows On OpenVMS VAX, the INT builtin would accept large unsigned numbers and silently convert them into negative integers. During the addition of 64-bit integer types to Compaq Pascal, it became apparent that this behavior was wrong. Now, when overflow checking is enabled, the INT builtin will signal a run-time error if its actual parameter cannot be represented as an INTEGER32 value. If you have a large unsigned value that you wish to convert to a negative integer, you must use a typecast to perform the operation. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES 1.9.2.6 Bound Procedure Values On OpenVMS VAX systems, a Bound Procedure Value is a 2-longword data structure holding the address of the entry point and a frame-pointer to define the nested environment. Compaq Pascal expects one of these 2-longword structures for PROCEDURE or FUNCTION parameters. Additionally, a called routine needs to be aware when it receives a Bound Procedure Value versus a simple routine address. When passing a routine to a %IMMED formal routine parameter, Compaq Pascal will pass the address of the entry point. On Tru64 UNIX, a Bound Procedure Value is just a special type of procedure descriptor which invokes a hidden jacket routine which in turns initializes the frame-pointer and calls the real routine. Given this structure, a routine that is calling another routine indirectly does not need to do anything special for Bound Procedure Values. Likewise, passing routines by %IMMED (or asking for the IADDRESS of a routine) passes the address of a procedure descriptor just as if the %IMMED wasn't present. There is no direct way in Compaq Pascal to obtain the actual code address of a routine since it isn't generally useful without the associated procedure descriptor. 1.9.2.7 Argument List Functions Since the Tru64 UNIX calling standard does not have architected method for determining an argument count, the ARGUMENT, ARGUMENT_LIST_LENGTH, and PRESENT builtin routines are not support on Tru64 UNIX. In addition, the [TRUNCATE] attribute is not support and the [LIST] attribute can only be used on external routine definitions. 1.9.2.8 %DICTIONARY Directive The %DICTIONARY directive is not supported on Tru64 UNIX. 1.9.2.9 VAX Floating Datatypes None of the VAX floating datatypes are supported on Tru64 UNIX (F_FLOAT, G_FLOAT, D_FLOAT, and H_FLOAT). In addition, the only the IEEE_FLOAT option to the [FLOAT()] attribute is supported. 1.9.2.10 Relative And Indexed Files Several keywords on the OPEN and CLOSE statement are not supported on Digtal UNIX systems. These include the DEFAULT; DISPOSITION := PRINT, COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES PRINT_DELETE, SUBMIT, and SUBMIT_DELETE; SHARING; USER_ACTION; and RECORD_TYPE := STREAM, STREAM_CR keywords. In addition, the DELETE, FIND, FINDK, LOCATE, RESETK, UPDATE, and UNLOCK builtin routines are not supported. 1.9.3 Calling C Routines From Pascal The calling sequence for Pascal parameters that are passed to C routines is documented in Chapter 6 in the "Compaq Pascal User Manual for Tru64 UNIX" manual. However, the documentation does not mention how to pass strings from Pascal to C routines. One method would be to use the newly added null-terminated string support routines (see the earlier section in these release notes). The other method is to use the existing Pascal mechanisms and decode the Pascal-specific descriptor passed to the C routines. Here is summary of the calling sequences used by Pascal for various parameters. Note that for parameters passed with value semantics, the compiler assumes that any data pointed to by the argument list or descriptors is not modified by the called routine. o For non-conformant parameters (both VAR and value semantics), a pointer to the variable (or expression) is passed. Compaq Pascal does not pass any arguments by "immediate value" by default. If you want this behavior, you can place the [IMMEDIATE] attribute on the formal parameter definition or use the %IMMED foreign mechanism specifier on the actual parameter. o For conformant array parameters without a CLASS_S attribute (both VAR and value semantics), a pointer to a Pascal-specific descriptor is passed. The descriptor (subject to change) looks like: struct { long pointer-to-data long total-data-size long element-size long pointer-to-virtual-base (aka, A[0] pointer) long dim-1-lower-bound long dim-1-upper-bound long dim-1-stride } with the last 3 longs repeated for any additional dimensions. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES o For conformant array parameters with a CLASS_S attribute (both VAR and value semantics), a pointer to a Pascal-specific descriptor is passed. The descriptor (subject to change) looks like: struct { long pointer-to-data long data-size } o For conformant varying parameters (both VAR and value semantics), a pointer to a Pascal-specific descriptor is passed. The descriptor (subject to change) looks like: struct { long pointer-to-varying-data long maximum-length } 1.10 Problems Corrected Since Last Release Of Compaq Pascal o The UPPER and LOWER builtin routines would return a signed value even when an unsigned type was specified. This problem has been fixed. o The compiler would incorrectly apply alignment padding to PACKED RECORDs if explicit POS attributes were used on record fields and natural alignment was requested (either by default on Alpha systems or explicitly on VAX systems). This problem has been fixed. o An Internal Compiler Error occurred when initializing a PACKED ARRAY OF CHAR larger than 8192 characters with a null-string. This problem has been fixed. o The compiler produced incorrect debug information for procedure parameters. This caused dbx to get an internal error when the 'where' command was used. This problem has been fixed. COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES o The compiler produced incorrect code for some binary set operations when one of the operands is a set literal whose size is smaller than the other operand. This problem has been fixed. o The compiler produced incorrect code when passing a set variable with an explicit size attribute to a VAR parameter or a builtin routine such as HEX. This problem has been fixed. o An Internal Compiler Error during syntax analysis occurred when an error message had more than 7 additional secondary messages. This problem has been fixed. o An Internal Compiler Error during syntax analysis could sometimes occur when the type of a foreign parameter was not declared before using it. This problem has been fixed. o The compiler did not realize that a nested routine passed to a procedure parameter of an external routine should be considered globally visible since the nested routine could be called from the external module. This resulted in the compiler making assumptions about the nested routine that it should not have made. This problem has been fixed. o The compiler generated incorrect code for value SET parmeters whose base type had an explicit size attribute larger than the necessary number of bits. The code in the routine's prolog that made the local copy did not initialize all the bits in the local copy. This problem has been fixed. o The compiler generated incorrect code for array constructors whose index types are enumerated types and /ENUM=BYTE was specified. This problem has been fixed. o The compiler would issue an incorrect warning message when assigning into a function result larger than 64-bits when /GRANULARITY=BYTE was specified on the compilation. This problem has been fixed. o The compiler would generate incorrect code for recursive routines that contained [STATIC] variables. The compiler didn't realize that the recursive call (either directly or indirectly) could modify the [STATIC] variable. This problem COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES has been fixed. o The compiler aborted with the internal compiler error message compiling programs which used the %DESCR foreign mechanism specifier for routine parameters. Using %DESCR on a routine does not make sense on OpenVMS Alpha. It is now diagnosed as not being supported on this platform. o The Compilation Summary did not list the correct number of total lines if the program used include files. This problem has been fixed. o Add the NONGRNACC keyword to the /USAGE qualifier and -usage switch. o Enable some default settings for the -usage keyword. If you wish to revert to the old behavior, use -usage none. o The compiler produced incorrect debug information for the predeclared TIMESTAMP type. This problem has been fixed. o The compiler produced incorrect code when assigning into a varying string when the right side of the assignment statement contained SUBSTRs of the same varying string. This problem has been fixed. o Add the /INCLUDE qualifier on OpenVMS and enhance the -I switch on Digital UNIX to specify default filename/pathname information for %INCLUDE directives and [INHERIT] attributes. o An Internal Compiler Error or incorrect code would occur when writing a varying string expression into a file declared as an [UNSAFE] FILE OF [UNSAFE] CHAR). This problem has been fixed. o The compiler generated incorrect information in its cross-reference listing (/CROSS_REFERENCE and -show xref) when passing a variable to a value parameter. This problem has been fixed. o An Internal Compiler Error would occur when fetching elements of a conformant array parameter whose elements contained COMPAQ PASCAL V5.7-81 FOR TRU64 UNIX RELEASE NOTES run-time sized types. This problem has been fixed. o Add the conditional-compilation directives (%IF, %THEN, %ELSE, etc.) o The /NOWARNING qualifier and -nowarn switch would accidently prevent error and fatal messages from being emitted from the compiler as well. This problem has been fixed. o Add the /CONSTANT qualifier on OpenVMS and the -constant option on Digital UNIX to specify constants from the command line.