XL C/C++ compiler diagnostic aids

Compilation return codes
XL C/C++ compiler listings
Header section
Options section
Source section
Error message format
Transformation report section
Attribute and cross-reference section
Object section
File table section
Compilation unit epilogue section
Compilation epilogue section
Debugging compiled applications

XL C/C++ issues diagnostic messages when it encounters problems compiling your application. You can use these messages to help identify and correct such problems.

This section provides a brief overview of the main diagnostics messages offered by XL C/C++. For more information about related compiler options that can help you resolve problems with your application, see Options for error checking and debugging and Options that control listings and messages.

Compilation return codes

At the end of compilation, the compiler sets the return code to zero under any of the following conditions:

Otherwise, the compiler sets the return code to one of the following values:

Return Code Error Type
1 An error with a severity level higher than the setting of the -qhalt compiler option has occurred.
40 An option error or unrecoverable error has occurred.
41 A configuration file error has occurred.
250 An out-of-memory has occurred. The compiler invocation command cannot allocate any more memory for its use.
251 A signal-received error has occurred. That is, an unrecoverable error or interrupt signal has occurred.
252 A file-not-found error has occurred.
253 An input/output error has occurred - files cannot be read or written to.
254 A fork error has occurred. A new process cannot be created.
255 An error has been detected while the process was running.
Note:
Return codes may also be displayed for runtime errors.

XL C/C++ compiler listings

Header section
Options section
Source section
Error message format
Transformation report section
Attribute and cross-reference section
Object section
File table section
Compilation unit epilogue section
Compilation epilogue section

Diagnostic information is produced in the output listing according to the settings of the -qlist, -qsource, -qxref, -qattr, -qreport, and -qlistopt compiler options. The -S option generates an assembler listing in a separate file.

If the compiler encounters a programming error when compiling an application, the compiler issues a diagnostic message to the standard error device and, if the appropriate compiler options have been selected, to a listing file.

To locate the cause of a problem with the help of a listing, you can refer to:

A heading identifies each major section of the listing. A string of greater than symbols precede the section heading so that you can easily locate its beginning:

>>>>> section name

You can select which sections appear in the listing by specifying the appropriate compiler options. For more information about these options see Options for error checking and debugging and Options that control listings and messages.

Header section

The listing file has a header section that contains the following items:

The header section is always present in a listing; it is the first line and appears only once. The following sections are repeated for each compilation unit when more than one compilation unit is present.

Options section

The options section is always present in a listing. There is a separate section for each compilation unit. It indicates the specified options that are in effect for the compilation unit. This information is useful when you have conflicting options. If you specify the -qlistopt compiler option, this section lists the settings for all options.

Source section

The source section contains the input source lines with a line number and, optionally, a file number. The file number indicates the source file (or include file) from which the source line originated. All main file source lines (those that are not from an include file) do not have the file number printed. Each include file has a file number associated with it, and source lines from include files have that file number printed. The file number appears on the left, the line number appears to its right, and the text of the source line is to the right of the line number. The compiler numbers lines relative to each file. The source lines and the numbers that are associated with them appear only if the -qsource compiler option is in effect.

If the -qsource option is in effect, the error messages are interspersed with the source listing. The error messages that are generated during the compilation process contain the following:

For example:

        7 |     for (i=0; i<100; i++) {
        8 |         for (j=0; j<100; j++) {
        9 |             a[i:j] = j;
"loop.c", line 9.16: 1506-277 (S) Syntax error: possible missing ',' or ']'?
       10 |         }
       11 |     }

If the -qnosource option is in effect, the error messages are all that appear in the source section, and an error message contains:

For example:

"loop.c", line 9.16: 1506-277 (S) Syntax error: possible missing ',' or ']'?

Error message format

The format of a C and C++ diagnostic message is:

Read syntax diagramSkip visual syntax diagram>>-15--cc-- ---nnn-- --+------------------------+--message_text-><
                       '-(--severity_letter--) -'
 

where:

15cc nnn
Indicates an XL C/C++ message and component number.
severity_letter
Indicates how serious the problem is, as described in the preceding section.

Compilation errors can have the following severity levels, which are displayed as part of some error messages:

U
An unrecoverable error. Compilation failed because of an internal compiler error.
S
A severe error. Compilation failed due to one of the following:
  • Conditions exist that the compiler could not correct.
  • An internal compiler table has overflowed. Processing of the program stops, and XL C/C++ does not produce an object file.
  • An include file does not exist. Processing of the program stops, and XL C/C++ does not produce an object file.
  • An unrecoverable program error has been detected. Processing of the source file stops, and XL C/C++ does not produce an object file. You can usually correct this error by fixing any program errors that were reported during compilation.
E
C compilations only. The compiler detected an error in your source code and attempted to correct it. The compiler will continue to compile your application, but might not generate the results you expect.
W
Warning message. The compiler detected a potential problem in your source code, but did not attempt to correct it. The compiler will continue to compile your application, but might not generate the results you expect.
I
Informational message. It does not indicate any error, just something that you should be aware of to avoid unexpected behavior.
'message text'
Is the text describing the error

By default, the compiler stops without producing output files if it encounters a severe error (severity S). You can make the compiler stop for less severe errors by specifying a different severity with the -qhalt option. For example, with -qhalt=w, the compiler stops if it encounters any errors of severity W or higher severity. This technique can reduce the amount of compilation time that is needed to check the syntactic and semantic validity of a program. You can limit low-severity messages without stopping the compiler by using the -qflag option.

Transformation report section

If the -qreport option is in effect, the compiler generates a transformation report showing how XL C/C++ optimized the program. This section displays pseudo-code that corresponds to the original source code, so that you can see parallelization and loop transformations generated by the -qhot or -qsmp options.

Attribute and cross-reference section

This section provides information about the entities that are used in the compilation unit. It is present if the -qxref or -qattr compiler option is in effect. Depending on the options in effect, this section contains all or part of the following information about the entities that are used in the compilation unit:

If you specify the full suboption with -qxref or -qattr, C and C++ reports all entities in the compilation unit. If you do not specify this suboption, only the entities you actually use appear.

Object section

XL C/C++ produces this section only when the -qlist compiler option is in effect. It contains a pseudo-assembler object code listing showing the source line number, the instruction offset in hexadecimal notation, the assembler mnemonic of the instruction, and the hexadecimal value of the instruction. On the right side, it also shows the cycle time of the instruction and the intermediate language of the compiler. Finally, the total cycle time (straight-line execution time) and the total number of machine instructions that are produced are displayed. There is a separate section for each compilation unit.

Note:
To obtain a true assembler listing, specify the -S compiler option when compiling your application. The assembler listing will be named filename.s.

File table section

This section contains a table that shows the file number and file name for each main source file and include file used. It also lists the line number of the main source file at which the include file is referenced. This section is always present.

Compilation unit epilogue section

This is the last section of the listing for each compilation unit. It contains the diagnostics summary and indicates whether the unit was compiled successfully. This section is not present in the listing if the file contains only one compilation unit.

Compilation epilogue section

The compilation epilogue section occurs only once at the end of the listing. At completion of the compilation, XL C/C++ presents a summary of the compilation: number of source records that were read, compilation start time, compilation end time, total compilation time, total CPU time, and virtual CPU time. This section is always present in a listing.

Debugging compiled applications

Specifying the -g or -qlinedebug compiler options at compile time instructs the XL C/C++ compiler to include debugging information in compiled output. You can then use dbx, the IBM Debugger for AIX, or any other symbolic debugger that supports the AIX XCOFF executable format to step through and inspect the behavior of your compiled application.