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: "tromey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 17 Oct 2016 20:38:43 +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
--- 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.