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

--- Comment #3 from Tom Tromey <tromey at gcc dot gnu.org> ---
(In reply to joseph@codesourcery.com from comment #2)

> Likewise an expression where the user did "typedef size_t my_size_t;" and 
> then used my_size_t.  And what about expressions resulting from arithmetic 
> on size_t values?  So it may be hard for the compiler to tell exactly what 
> expressions are appropriate for use with %zu (even without direct use of 
> __SIZE_TYPE__).

I think it's still preferable for gcc to be better about this even if it
can't be perfect.

First, in my particular case, I think all the types in question are just
"size_t" -- it's common to use this in spidermonkey.

Second, the problem I have is that I wanted to enable -Wformat.  So, I
wrote a bunch of patches -- which then failed to build on other arches.
In this case, if gcc had warned about size_t/%lu mixups in the code, while
perhaps I wouldn't have caught every possible cross-arch build bug, I
certainly would have far fewer of them.

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