Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
7779 Discussions

Compiler Warnings #2022, #2012, #383


Hello all,
I'm compiling my C++ application using icc v. 12, and enabled all warnings to see what the Intel compiler would say about my code. I've got warnings, of course, but some of them didn't make a lot of sense. For example,
warning #2022: Effective C++ Item 12 field member "numeric_kernel::b" not initialized (preferable to assignment in constructors)
For one variable that will be initialized inside the constructor because some calculation has to be done before it is assigned.
Other error:
warning #2012: Effective C++ Item 1 prefer const and inline to #define
#define FUNC_WRAP_H_
where the #define clearly refers to a definition of a .h file.
The last one,
remark #383: value copied to temporary, reference to temporary used
return -Q * z * exp(-I*angle);
inside a class method, where all the variables are members of the class. Can it be just compiler noise?
0 Kudos
1 Reply

As far as the effective C++ warnings are concerned thesewarnings about things that are sometimes bad
programming practice according to Scott Meyer's "Effective C++" book. Seeing a warning here doesn't mean the code isactually bad. I'm sure you'd see similar warnings if you used the -Weffc++ switch with the Gnu compiler.It is not possible for a compilerto get these exactly right, i.e. only issue the warnings on actual bad code.

If they seem to not be useful you should not use the -Weffc++ switch or you can disable the diagnosticsindividually.

The #383 remark is explained in our knowledge base here:

This is a remark, not a warning, so it may or may not indicate an actual coding mistake.