The Intel compiler really does not have good warning presets like gcc does (at least on Linux). The main warning option is -wn where n can be from 0 to 5. By default, 1, and 4 and 5 do not matter for Linux. It also supports some gcc options, such as -Wall and -Wextra . However:
-Wall very minimal compared to gcc, as you found-w2 and -w3 allow you to use some useful diagnostic tools, as well as a lot of spam notes-diag-disable:remark removes this spam, but also a lot of useful diagnostics
At the end, -w3 -diag-disable:remark best preset icc has, but it's still more minimalistic than gcc -Wall . Instead, you need to either start with a minimal set of warnings, or create your own, or start with maximum diagnostics and disable anything that is annoying using -wd .
Create
The main drawback of the first approach is that Intel does not document most of its warnings, so itβs hard to understand what is available for inclusion. However, it supports many GCC command line flags, so the GCC documentation is a good place to start. For example, here are settings that are relatively close to g++ -Wall , which is convenient if you want to develop with one and have good chances of a clean build with the other:
icpc -Wall -Warray-bounds -Wchar-subscripts -Wcomment -Wenum-compare -Wformat -Wuninitialized -Wmaybe-uninitialized -Wmain -Wnarrowing -Wnonnull -Wparentheses -Wpointer-sign -Wreorder -Wreturn-type -Wsign-compare -Wsequence-point -Wtrigraphs -Wunused-function -Wunused-but-set-variable -Wunused-variable -Wwrite-strings
This is not an exact match for gcc -Wall . There are differences between the GCC and the ICC regarding the above warnings. I also could not find ICC options to match these GCC warnings:
-Wformat-contains-nul -Wunused-label -Wstrict-overflow -Wvolatile-register-var
And I deliberately left them because the ICC version was much more spam than GCC:
-Wstrict-aliasing So broad that any use of polymophism will cause this warning -Wswitch Requires a default even if you have cases for all enumeration values
Trim down
If the parity of GCC is not a concern, then the easiest way to find out which warnings are ICCs is to turn them all on and then decide whether you like it or not. If you don't like the warning, you can turn it off using its diagnostic number, which often has a great deal of granularity that the GCC settings do.
icpc -w3 -wd1418,2259
Here are some diagnostic data I've seen in the past:
- 383: value copied to temporary, reference to temporary use
- 869: parameter "*" was never mentioned
- 981: operands evaluated in unspecified order
- 1418: definition of an external function without prior declaration
- 1572: Floating-point equality and comparison of inequalities are unreliable.
- 2259: conversion without a pointer may lose significant bits
- 11074: Invalidation is prohibited by the maximum size limit (or maximum total size)
- 11076: to get full use of the report -qopt-report = 4 -qopt-report-phase ipo
But I recommend that you start with them all and drop only those that are problematic for your code base.