How to handle warning messages in the compiler

Recently, I received several customer issues about how to handle warning messages in Intel compiler. To ease customer this kind of question, I summary related information of warnings, errors and remarks here.

 

Remarks

Remark messages report common but sometimes unconventional use of C or C++. The compiler does not print or display remarks unless you specify the /W4 option. Remarks do not stop translation or linking. Remarks do not interfere with any output files. The following are some representative remark messages:

*       function declared implicitly

*       type qualifiers are meaningless in this declaration

*       controlling expression is constant

Warnings

Warning messages report legal but questionable use of the C or C++. The compiler displays warnings by default. You can suppress all warning messages with the /w compiler option. Warnings do not stop translation or linking. Warnings do not interfere with any output files. The following are some representative warning messages:

*       declaration does not declare anything

*       pointless comparison of unsigned integer with zero

*       possible use of = where == was intended

Errors

These messages report syntactic or semantic misuse of C or C++. The compiler always displays error messages. Errors suppress object code for the module containing the error and prevent linking, but they allow parsing to continue to detect other possible errors. Some representative error messages are:

*       missing closing quote

*       expression must have arithmetic type

*       expected a ";"

Option Summary

Use the following compiler options to control remarks, warnings, and errors:

Option

Result

/w; -w

Disables all warning messages

/W0; -W0

Disables warnings; displays errors

/W1, /W2; -W1, -W2

Displays warnings and errors.

/W3; -W3

Displays remarks, warnings, and errors. This level is recommended for production purposes

/W4, /Wall; -W4, -Wall

Displays all level 3 (n=3) warnings plus informational warnings, which in most cases can be safely ignored.

/W5; -W5

Displays all remarks, warnings, and errors. This setting produces the most diagnostic messages

/WL; -Wbrief

Display brief one-line diagnostics

/Wcheck; -Wcheck

Enable more strict diagnostics

/Werror-all; -Werror-all

Change all warnings and remarks to errors

/WX; -Werror

Change all warnings to errors

You can also control the display of diagnostic information with variations of the /Qdiag compiler option. This compiler option accepts numerous arguments and values, allowing you wide control over displayed diagnostic messages and reports.

Some of the most common variations include the following:

Option

Result

/Qdiag-enable:list

-diag-enable list

Enables a diagnostic message or a group of messages

/Qdiag-disable:list

-diag-disable list

Disables a diagnostic message or a group of messages

/Qdiag-warning:list

-diag-warning list

Tells the compiler to change diagnostics to warnings

/Qdiag-error:list

-diag-error list

Tells the compiler to change diagnostics to errors

/Qdiag-remark:list

-diag-remark list

Tells the compiler to change diagnostics to remarks (comments)

The list items can be specific diagnostic IDs, one of the keywords warn, remark, or error, or a keyword specifying a certain group (par, vec, sc, driver, thread, par, port-linux,, sc,openmp).

Other diagnostic-related options include the following:

Option

Result

/Qdiag-dump

-diag-dump

Tells the compiler to print all enabled diagnostic messages and stop compilation

/Qdiag-file[:file]

-diag-file[=file]

Causes the results of diagnostic analysis to be output to a file

/Qdiag-file-append[:file]

-diag-file-append[=file]

Causes the results of diagnostic analysis to be appended to a file

/Qdiag-error-limit:n

-diag-error-limitn

Specifies the maximum number of errors allowed before compilation stops

 

For more complete information about compiler optimizations, see our Optimization Notice.

5 comments

Top
kehoste's picture

I found the answer to my own question.

To promote warning #10006 to an error, you can use the -we10006 flag. Works as expected.

kehoste's picture

Is there a way to 'promote' *selected* compiler warnings to errors?

E.g., how can I make the Intel compiler crash with an error is an unknown flag is being used? By default, this just shows a warning and continues (which is not desirable, imho):

icc: command line warning #10006: ignoring unknown option '-fp-relaxed'

anonymous's picture

E.g. by #pragma warning disable 1125!?

Sergey Kostrov's picture

The article is good but, unfortunately, it misses a very important part, that is how to control warnings and remarks in sources. For example, how could I disable in a source file (!) a warning:

...
Warning #673: the initial sequence of preprocessing directives is not compatible with those of precompiled header file "Debug<ProjectName>.pchi"
...

Victor Pasko (Intel)'s picture

Well, what about disabling compiler remarks?

I can see only options for warnings:
/w -w Disables all warning messages

E.g. -vec-report0 - Disables vectorization remarks
But there are many other compiler remarks: like paralellization remarks, etc.

It would be helpfull to expant this article with such info.

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.