- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By compiling all my programs with -Wall option, I was under impression I would get all relevant warnings, which compiler can provide.
But apparently, format errors on string manipulation (quite a big error with potential small, hard to discover memory overwrites) is not reported, even if compiler has diagnostics to do it.
#include <stdio.h> #include <stdlib.h> int main() { static unsigned char a=1, b=2, c=3; char *numStr="123"; sscanf(numStr, "%d", &b); printf("%d %d %d\n", a, b, c); return(0); }
By compiling it with this command I don't get any warning.
icc -Wall bug.c
but if I compile it with gcc
gcc -Wall bug.c
I get proper warning:
bug.c: In function 'main':
bug.c:8:19: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'unsigned char *' [-Wformat=]
sscanf(numStr, "%d", &b);
~^ ~~
which also tells me which compiler option triggered the warning (-Wformat)
So I try it with icc, and I get
icc -Wformat bug.c
bug.c(8): warning #181: argument of type "unsigned char *" is incompatible with format "%d", expecting argument of type "int *"
sscanf(numStr, "%d", &b);
So why is -Wformat not included in -Wall ?
My operating system is Linux, OpenSUSE 15, 64 bits.
And this is the version of my compiler:
icc (ICC) 19.1.0.166 20191121
Copyright (C) 1985-2019 Intel Corporation. All rights reserved.
- Tags:
- Bug
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK, we don't have such a list. And I've submitted this bug to our Developer for a fix.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reporting this issue. Ideally, "-Wall" must include "-Wformat" warnings as well. We will take this issue to the concerned team.
--Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ICC's diagnosis may behave different than GCC's. You can add -ww181 to turn on this warning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Viet Hoang (Intel) wrote:ICC's diagnosis may behave different than GCC's. You can add -ww181 to turn on this warning.
I understand that gcc and icc are different, and I know how to enable -Wformat in icc.
My question is why icc does not include -Wformat among -Wall, since that warning is both serious and quite basic.
Or if someone can point me to the list of warnings that are included in -Wall, so I will know which others do I need to include manually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK, we don't have such a list. And I've submitted this bug to our Developer for a fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately, we wont fix this issue. Please use -ww181 to turn on this warning.
I am going to close this case.
Thanks,
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page