Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Where is the online documentation for suppressing warnings

Andreas_Fabri__Geome
3,222 Views

 

I am looking for the official documentation of how to suppress specific warnings for ICL, for Windows and for Linux.

 

0 Kudos
14 Replies
TimP
Honored Contributor III
3,222 Views

Did you look up diag-disable either in the index to on-line documentation or under ICL -help ?

0 Kudos
Andreas_Fabri__Geome
3,222 Views

In fact I want to disable them more locally than a whole compilation unit.

I am looking for something  similiar to 

_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")

0 Kudos
Judith_W_Intel
Employee
3,222 Views

 

icc -help-pragma filename

will list all the supported pragmas and their syntax.

They are also described here:

https://software.intel.com/en-us/node/524492

I think the one you are looking for is

#pragma warning (push)

#pragma warning (disable:number)

...

#pragma warning (pop)

More details in the Microsoft documentation:

https://msdn.microsoft.com/en-us/library/2c8f766e.aspx

 

 

 

 

0 Kudos
Andreas_Fabri__Geome
3,222 Views

Note that I am looking for a solution for Linux.

0 Kudos
Judith_W_Intel
Employee
3,222 Views

 

The above pragmas work on Linux with our compiler.

0 Kudos
KitturGanesh
Employee
3,222 Views

BTW, the link https://software.intel.com/en-us/intel-software-technical-documentation  provides documentation access to compiler component and all the other supported SW products.

_Kittur

0 Kudos
Andreas_Fabri__Geome
3,222 Views

Hello,

@Kittur: A top level link is not really helpful for a precise question.

@Judith:  What works for us is:

#pragma warning disable 1017

WITHOUT a  ":" between "disable" and the number.

The compiler is

Compiler version:
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.1.150 Build 20151021

push and pop  do NOT work.

Best regards,

andreas

0 Kudos
KitturGanesh
Employee
3,222 Views

Thanks Andreas, I just added the general link as an add on info to what Judy had already provided for the question.  Also, I'll pass on your feedback on push/pop not working and will try that out. If an issue I'll file with developers as well - appreciate much.
_Kittur

0 Kudos
Judith_W_Intel
Employee
3,222 Views

Yes you are right the syntax is a bit different on Linux.

Could you provide an example that shows that push/pop is not working properly?

Here is an example which shows it is working:

sptxl15-37> cat foo.cpp

struct C {
  void f();
};

template <class T>
void foo() {
  C* c = new C;
#pragma warning(push)
#pragma warning disable 1017
  c->template f(); // warning disabled here
#pragma warning(pop)
  c->template f();  // but not here
}


sptxl15-38> icpc -c -strict_ansi foo.cpp
foo.cpp(13): warning #1017: name following "template" must be a template
    c->template f();  // but not here
                ^

sptxl15-39>'

 

thanks again

Judy

0 Kudos
KitturGanesh
Employee
3,222 Views

Hi Andreas,  the push/pop works for me as well and I couldn't reproduce the problem.  A reproducer would come in handy, thanks. 
_Kittur

0 Kudos
KitturGanesh
Employee
3,222 Views

Hi Andreas, can you provide a reproducer for the push/pop issue? Appreciate much for your help.
_Kittur

0 Kudos
KitturGanesh
Employee
3,222 Views

Hi Andreas, any update on the reproducer for the push/pop issue you mentioned (as it works on our systems and couldn't reproduce as communicated to you earlier)?

Kittur

0 Kudos
Max_S
Beginner
3,140 Views

This is a reproducer:

 

#include <iostream>

template<typename T>
struct S1 {
  void func() { std::cout<< "Creates no warning, is inlined" << std::endl;}
};

#pragma warning push
#pragma warning disable 2196
template<typename T>
struct S2 {
  __attribute__((noinline)) void func() { 
    std::cout<< "Creates warning, is not inlined" << std::endl;
  }
};
#pragma warning pop

template<typename T>
struct S3 {
  __attribute__((noinline)) void func();
};

template<typename T>
void S3<T>::func() { std::cout<< "Creates no warning, is not inlined" << std::endl;}

int main(int nargs, char** args) {
  S1<int> s1; 
  s1.func();

  S2<int> s2; 
  s2.func();

  S3<int> s3; 
  s3.func();
}

 Tested with intel 2020 and 2019. When the pop is removed, then the warning is suppressed.

 

Output is:

intelExample.cpp(36): warning #2196: routine is both "inline" and "noinline"

 

0 Kudos
Viet_H_Intel
Moderator
3,108 Views

Thank for the test case. You can use -diag-disable=2196 to suppress the warning.

0 Kudos
Reply