I have a large code base that has recently migrated from the Microsoft compiler to the Intel C ++ compiler. Our team goal is compilation without warnings in the trunk. Since the switch, one warning case 167 confused me. If I compile the following code:
int foo(const int pp_stuff[2][2]) { return 0; } int foo2(const int pp_stuff[][2]) { return 0; } int main(void) { int stuff[2][2] = {{1,2},{3,4}}; foo(stuff); foo2(stuff); return 0; }
ICC will give me warnings:
1>main.c(17): warning #167: argument of type "int (*)[2]" is incompatible with parameter of type "const int (*)[2]" 1> foo(stuff); 1> ^ 1> 1>main.c(18): warning #167: argument of type "int (*)[2]" is incompatible with parameter of type "const int (*)[2]" 1> foo2(stuff);
Why should this be a warning? It is usually customary to pass a non-constant variable as a const parameter, and the types and sizes are identical.
For those who noted this duplicate question, I urge you to reconsider. If anyone else comes across this warning, they should be aware that they are converted in C arguments, as if they were assigned in prototyped functions, and then looked for a question that is strictly related to assignment. Although the answer ends with the same sentence from C90 / C99, the question, I think, is very different.
Phill source share