- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like in some cases ICC doesn't notice a noreturn attribute of the called function. Below is a simple example that illustrates the problem.
(In practice, in my program abort() is called from ASSERT() macro that does something more, but the key point is the usage of comma operator).
#include <stdlib.h> int noret1(void) { abort(), 0; /* warning #1011 */ abort(), abort(); /* warning #1011 */ }
int noret2(void) { abort(); /* ok - no warning */ } int main(int argc, const char *argv[]) { return noret1() + noret2(); }
- 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
You can use -Wall or -ww1011 to get the warning.
vahoang@orcsle100:/tmp$ icc t.c -c -Wall
t.c(3): warning #1011: missing return statement at end of non-void function "noret2"
}
^
vahoang@orcsle100:/tmp$ icc t.c -c -ww1011
t.c(3): warning #1011: missing return statement at end of non-void function "noret2"
}
Regards,
Viet Hoang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for response, but I'm not sure what you mean.
The point is I don't want to see this warning, even with -Wall. There is no bug in the example code - because of abort() (which does not return) the end of the function would never be reached (which is intentional), so it doesn't matter if there is return statement or not.
gcc and clang do not throw a warning in such case. icc does, but only if comma operator is used (noret1). I suspect it to be a bug in the compiler (icc version 17.0.4).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What ICC version are you using? I dont see an error with ICC 17.0.4 version.
Thanks,
Viet Hoang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[vahoang@bec-dev3-x64 tmp]$ cat tt.c
#include <stdlib.h>
int noret1(void) {
abort(), 0; /* warning #1011 */
abort(), abort(); /* warning #1011 */
}
int noret2(void) {
abort(); /* ok - no warning */
}
int main(int argc, const char *argv[]) {
return noret1() + noret2();
}
[vahoang@bec-dev3-x64 tmp]$ icc tt.c -c
[vahoang@bec-dev3-x64 tmp]$ icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.4.196 Build 20170411
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
[vahoang@bec-dev3-x64 tmp]$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[krzycz@krzycz-fedora ~]$ cat tt.c
#include <stdlib.h>
int noret1(void) {
(void)(abort(), 0); /* this what my ASSERT() evaluates to */
}
int noret2(void) {
abort(); /* ok - no warning */
}
int main(int argc, const char *argv[]) {
return noret1() + noret2();
}
[krzycz@krzycz-fedora ~]$ gcc -Wall ./tt.c
[krzycz@krzycz-fedora ~]$ clang -Wall ./tt.c
[krzycz@krzycz-fedora ~]$ /opt/intel/bin/icc -Wall ./tt.c
./tt.c(5): warning #1011: missing return statement at end of non-void function "noret1"
}
^
[krzycz@krzycz-fedora ~]$

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