Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

ICC: Multiple issues when header not included

$
0
0

With ICC 19.0.1.144 as well as older versions I experience the following behavior which I think are bugs in the compiler:

Take the following very simple code:

---
#include

int main (int argc, char* argv[]) {
printf("%f\n", fabs(0.5));
return 0;
}
---

It's missing an include of for fabs(). However, when compiling it with ICC using -Wmissing-prototypes I receive no warning. Instead it silently generates a prototype for fabs() and works as intended:

---
$ icc -Wmissing-prototypes -o test test.c
$ ./test
0.500000
---

Using -Wall also does not show it. Is that how it's supposed to be?

Now, here comes the second issue: If I compile the code with -g to include debugging symbols, ICC suddenly thinks of a wrong signature for fabs(), returning an int. Again, I receive no warning about the missing prototype:

---
$ icc -g -Wmissing-prototypes -o test test.c
$ ./test
0.000000
---

Note that the behavior of the program changed by adding -g to the compiler call. This does not seem right to me... One gets a bit more insight into this calling icc with -Wall, since printf() isn't happy here:

---
test.c(4): warning #181: argument of type "int" is incompatible with format "%f", expecting argument of type "double"
printf("%f\n", fabs(0.5));
^
---


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>