- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using ICC Version 19.0.6 Build 20191202 to build on Ubuntu 18.04.1.
I found that the warning [-Wunused_function] only take class into consideration, meaning if the member function of a class is never referenced, it trigger the warning, however while if a free function is never referenced, no such warning will be shown. I also try on GCC, which shows a opposite behavior.
For example, the following cpp codes will trigger no warning by ICC, but a warning [-Wunused_function] by GCC.
static void SFoo() { return;} int main() { return 0; }
Is the behavior of ICC expected?
- Tags:
- CC++
- Development Tools
- General Support
- 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
Hi,
Could you also specify your gcc version?
You are right, in case free function is not being referenced, "gcc" throws a warning, but "icc" doesn't. However, in case class member function is not being referenced, both icc and gcc are not throwing any warning. Tried with icc version 19.1 and gcc version 7.4.0 using "-Wall" flag.
-Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rahul,
The GCC version is: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
The result you see is the same regarding GCC behavior, but for ICC, your result differs from mine.
Mine result shows ICC throws warning for class, and only for class.
My ICC Version is 19.0.6 and yours is 19.1, maybe that's why the different behavior.
What's the expected behavior? throw warning or not for class?
--Liang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Liang,
We are investigating this query with the Intel engineering team and we will get back to you at the earliest.
-Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't have the exact icc/gcc versions which you have. But I don't see any differences with icc 19.0.5, 9.1.0, gcc7.3.0 and 8.1.0
$ icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.5.281 Build 20190815
Copyright (C) 1985-2019 Intel Corporation. All rights reserved.
$ icc t.c -c -Wunused-function
t.c(1): warning #177: function "SFoo" was declared but never referenced
static void SFoo() { return;}
^
$ gcc t.c -c -Wunused-function
t.c:1:13: warning: ‘SFoo’ defined but not used [-Wunused-function]
static void SFoo() { return;}
^~~~
$ icpc t.cpp -c -Wunused-function
t.cpp(1): warning #177: function "SFoo" was declared but never referenced
static void SFoo() { return;}
^
$ g++ t.cpp -c -Wunused-function
t.cpp:1:13: warning: ‘void SFoo()’ defined but not used [-Wunused-function]
static void SFoo() { return;}
^~~~
$ g++ t.cpp -c
$ icpc t.cpp -c
$ gcc t.c -c
$ icc t.c -c
$ cat t.c
static void SFoo() { return;}
int main()
{
return 0;
}
$ cat t.cpp
static void SFoo() { return;}
int main()
{
return 0;
}
How do I reproduce the differences?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Viet,
My ICC version is Version 19.0.6 Build 20191202, different from yours. It could be the reason why you cannot reproduce the issue.
--Liang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you add -ww177 to your command line to see if the compiler emits the warning?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Viet
After experiment, the behavior is
icc -ww177: both free function and class member function can emit warning#177
icc -Wall: only class member function can emit warning#177
Does the behavior expected?
--Liang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It isn't expected, but you can use -ww177 as a workaround. And the latest compiler emits the correct warning to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let us know if this is still an issue. Otherwise, we will close it.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We will no longer respond to this thread.
If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.
Thanks,

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page