This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/78014] -Wformat -vs- size_t
- From: "dgilbert at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 16 Jun 2017 11:04:39 +0000
- Subject: [Bug c++/78014] -Wformat -vs- size_t
- Auto-submitted: auto-generated
- References: <bug-78014-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78014
Dr. David Alan Gilbert <dgilbert at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dgilbert at redhat dot com
--- Comment #7 from Dr. David Alan Gilbert <dgilbert at redhat dot com> ---
A similar variant is:
#include <stdio.h>
int main(int argc, char *argv[])
{
size_t s = 42;
printf("%d\n", s);
}
t.c:7:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2
has type ‘size_t {aka long unsigned int}’ [-Wformat=]
printf("%d\n", s);
~^
%ld
I'd expect it to be suggesting %zd here.
The difference in this case is it's already generating a warning - just not the
one I'd expect (and it already knows it's size_t).