Compiler Message System Use

This topic describes how to use the message system to control and use messages issued by the compiler.

This topic describes how to use the message system to control and use messages issued by the compiler. Explanatory texts for messages can be displayed online through the use of the explain command.

Expand Messages with the explain Command

Use the explain command to display an explanation of any message issued by the compiler. The command takes as an argument, the message number, including the number's prefix. The prefix for Cray C and C++ is CC.

In the following sample dialog, the cc command invokes the compiler on source file bug.c. Message CC-24 is displayed. The explain command displays the expanded explanation for this message.
% cc bug.c
CC-24 cc: ERROR File = bug.c, Line = 1
   An invalid octal constant is used.

   int i = 018;
             ^

1 error detected in the compilation of "bug.c".
% explain CC-24

An invalid octal constant is used.

Each digit of an octal constant must be between 0 and 7, inclusive. One or
more digits in the indicated octal constant are outside of this range.
Change each digit in the octal constant to be within the valid range.

Control the Use of Messages

This section summarizes the command line options that affect the issuing of messages from the compiler.

-h errorlimit[=n]
Specifies the maximum number of error messages the compiler prints before it exits.
-h [no]message=n[:...]
Enables or disables the specified compiler messages, overriding -h msglevel.
-h msglevel_n
Specifies the lowest severity level of messages to be issued.
-h [no]msgs
Enables or disables the writing of optimization messages to stderr.
h [no]negmsgs
Enables or disables the writing of messages to stderr that indicate why optimizations such as vectorization, inlining, or cloning did not occur in a given instance.
-h report=args
Generates optimization report messages.
The following are used by the message system:
NLSPATH
Specifies the default value of the message system search path environment variable.
LANG
Identifies the requirements for native language, local customs, and coded character set with regard to the message system.
MSG_FORMAT
Controls the format in which error messages are received.
Override the command name printed in the message. If the environment variable ORIG_CMD_NAME is set, the value of ORIG_CMD_NAME is used as the command name in the message. This functionality is provided for use with shell scripts that invoke the compiler. By setting ORIG_CMD_NAME to the name of the script, any message printed by the compiler appears as though it was generated by the script. For example, the following C shell script is named newcc:
#
setenv ORIG_CMD_NAME 'basename $0'
cc $*
A message generated by invoking newcc resembles the following:
CC-8 newcc: ERROR File = x.c, Line = 1
  A new-line character appears inside a string literal.

Because the environment variable ORIG_CMD_NAME is set to newcc, this appears as the command name instead of cc in this message.

The ORIG_CMD_NAME environment variable is not part of the message system. It is supported by the Cray C and C++ compilers as an aid to programmers. Other products, such as the Fortran compiler and the linker, may support this variable. However, do not rely on support for this variable in any other product.

Be careful when setting the environment variable ORIG_CMD_NAME. If setting ORIG_CMD_NAME inadvertently, the compiler may generate messages with an incorrect command name. This may be particularly confusing if, for example, ORIG_CMD_NAME is set to newcc when the Fortran compiler prints a message. The Fortran message will look as though it came from newcc.

Message Severity

Each message issued by the compiler falls into one of the following categories of messages, depending on the severity of the error condition encountered or the type of information being reported.
COMMENT
Inefficient programming practices.
NOTE
Unusual programming style or the use of outmoded statements.
CAUTION
Possible user error. Cautions are issued when the compiler detects a condition that may cause the program to abort or behave unpredictably.
WARNING
Probable user error. Indicates that the program will probably abort or behave unpredictably.
ERROR
Fatal error; that is, a serious error in the source code. No binary output is produced.
INTERNAL
Problems in the compilation process. Please report internal errors immediately to the system support staff, so that a bug report can be filed.
LIMIT
Compiler limits have been exceeded. Normally, the source code or environment can be modified to avoid these errors. If limit errors cannot be resolved by such modifications, please report these errors to the system support staff, so that a bug report can be filed.
INFO
Useful additional information about the compiled program.
INLINE
Information about inline code expansion performed on the compiled code.
SCALAR
Information about scalar optimizations performed on the compiled code.
VECTOR
Information about vectorization optimizations performed on the compiled code.
OPTIMIZATION
Information about general optimizations.
IPA_INFO
Information about interprocedural optimizations.

Common System Messages

The errors in the following list can occur during the execution of a user program. The operating system detects them and issues the appropriate message. These errors are not detected by the compiler and are not unique to C and C++ programs; they may occur in any application program written in any language.
  • Operand Range Error

    An operand range error occurs when a program attempts to load or store in an area of memory that is not part of the user's area. This usually occurs when an invalid pointer is dereferenced.

  • Program Range Error

    A program range error occurs when a program attempts to jump into an area of memory that is not part of the user's area. This may occur, for example, when a function in the program mistakenly overwrites the internal program stack. When this happens, the address of the function from which the function was called is lost. When the function attempts to return to the calling function, it jumps elsewhere instead.

  • Error Exit

    An error exit occurs when a program attempts to execute an invalid instruction. This error usually occurs when the program's code area has been mistakenly overwritten with words of data (for example, when the program stores in a location pointed to by an invalid pointer).