This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/78014] -Wformat -vs- size_t


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).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]