- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 <stdio.h> int main (int argc, char* argv[]) { printf("%f\n", fabs(0.5)); return 0; }
It's missing an include of math.h 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:
$ icc -g -Wall -o test test.c 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)); ^
(Post edited on 01/12/2019 to fix formatting and missing includes)
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are there anything that I've missed as I couldn't compile your test case.
vahoang@orcsle147:/tmp$ icc t.c -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.1.144 Build 20181018
t.c(1): catastrophic error: expected a file name
#include
^
compilation aborted for t.c (code 4)
vahoang@orcsle147:/tmp$
vahoang@orcsle147:/tmp$ cat t.c
#include
int main (int argc, char* argv[]) {
printf("%f\n", fabs(0.5));
return 0;
}
vahoang@orcsle147:/tmp$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the forum software has removed all parts of my post containing angle brackets... For some reason I didn't have a proper editor when creating this post. Here's the code again:
#include <stdio.h> int main (int argc, char* argv[]) { printf("%f\n", fabs(0.5)); return 0; }
And it's missing an include of math.h.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For the first issue, you can add -w to see the warning.
vahoang@orcsle147:/tmp$ icc t.c -w3
t.c(5): remark #266: function "fabs" declared implicitly
printf("%f\n", fabs(0.5));
^
I'll get back to you on the second one.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another way to get the warning is to compile with -Wimplicit-function-declaration
I've reported the second issue to our developer. The tracking number is CMPLRIL0-31028
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, indeed I confused -Wmissing-prototypes with -Wimplicit-function-declaration. But shouldn't -Wall include -Wimplicit-function-declaration?
Thanks for filing the problem report regarding the second issue!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page