Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
23 Views

Unnecessary warnings

Hello,

Compiling the following piece of code produces unnecessary warnings (warning #175: subscript out of range) with icpc version 13.0.0 (gcc version 4.6.3 compatibility), could you please tell me why ? Template parameters are evaluated at compile time before code generation right ?

[cpp]template<int T> void fun() {
    int foo[2 + (T == 0)];
    if(T == 0)
        foo[2] = 2;
    else
        foo[1] = 2;
}

int main()
{
    fun<2>();
    fun<0>();
}
[/cpp]

0 Kudos
7 Replies
Highlighted
Employee
23 Views

Hello, that's a bug for which I filed a defect (DPD200239677). This warning should not occur at all. I'll let you know once we fixed this issue. Thank you for finding this! Best regards, Georg Zitzlsberger
0 Kudos
Highlighted
Employee
23 Views

Hello, I need to correct my initial assumption: It's not a bug but a missing feature in our compiler front-end. Detecting evaluations of conditions requires additional logic that we don't have (yet). Unfortunately it's not easy to implement and is not planned. Other compilers are known to not detect potential problems like that at all. So, we could regard this as an additional benefit to warn about such potential problems, even though we're overly sensitive. Best regards, Georg Zitzlsberger
0 Kudos
Highlighted
Beginner
23 Views

Georg Zitzlsberger (Intel) wrote:

Other compilers are known to not detect potential problems like that at all. So, we could regard this as an additional benefit to warn about such potential problems, even though we're overly sensitive.

GCC doesn't detect such potential problems indeed, however clang (3.0 or newer) does it, and better than icc (no warning at all with -Warray-bounds, which is the expected behavior).
0 Kudos
Highlighted
Valued Contributor II
23 Views

Hi everybody, I detected that problem in June 2012 and it was in my 'List of issues / problems' with a lowest priority ( I'm sorry about this ). It is good to know that Georg confirmed that this is due to some issues with the compiler. I gave the lowest priority because I didn't consider it as a problem with the Intel C++ compiler ( 12.1.3.300 ) or with a piece of my codes. So, here are some technical details: [ Warning #175: Subscript out of range ] ------ Build started: Project: IccTestApp, Configuration: Debug Win32 ------ Compiling with Intel(R) C++ Compiler XE 12.1.3.300 [IA-32]... (Intel C++ Environment) Stdphf.cpp ... ..\DataSet.h(194): warning #175: subscript out of range if( g_uiVALUESETsizeof[ iDataType - _RTVALUESET_STARTINDEX ] == sizeof( T ) && ^ detected during instantiation of "TDataSet< T, iDataType >::TDataSet() [with T=RTfloat={float}, iDataType=3]" at line 425 of "../TestSet.cpp" ... Compiling with Intel(R) C++ Compiler XE 12.1.3.300 [IA-32]... (Intel C++ Environment) IccTestApp.cpp Compiling manifest to resources... (Microsoft VC++ Environment) Linking... (Intel C++ Environment) xilink: executing 'link' Creating library ..\Debug\IccTestAppD.lib and object ..\Debug\IccTestAppD.exp Embedding manifest... (Microsoft VC++ Environment) IccTestApp - 0 error(s), 16 warning(s), 0 remark(s) Best regards, Sergey
0 Kudos
Highlighted
Valued Contributor II
23 Views

>>...Detecting evaluations of conditions requires additional logic that we don't have (yet)... In my case a variable 'iDataType' is evaluated at runtime and it is always greater than 0. So, if at compile time the compiler assumes a 0 value for the variable 'iDataType' than an expression ( iDataType - _RTVALUESET_STARTINDEX ) is less then 0 and there is a "false attempt" to access some memory outside of array 'g_uiVALUESETsizeof' and this is by design of that piece of code. Once again, that is why I didn't consider it as an error.
0 Kudos
Highlighted
Beginner
23 Views

Why is this still not fixed ?

Thanks.

0 Kudos
Highlighted
Employee
23 Views

Hello,

I've had a look at the feature request. The problem here is that it would require large changes in the compiler FE to do the analysis. Trading off the amount of work needed for getting rid of a warning, we have refrained from implementing this feature request.

Nevertheless, you can turn off warnings like that if you want: -diag-disable=175 or /Qdiag-disable:175

Best regards,

Georg Zitzlsberger

0 Kudos