Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warning on Windows with clang #21

Closed
ghost opened this issue Jul 27, 2015 · 2 comments
Closed

Build warning on Windows with clang #21

ghost opened this issue Jul 27, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 27, 2015

Originally reported on Google Code with ID 21

http://build.chromium.org/p/chromium.fyi/builders/Cr%20Win%20Clang/builds/108/steps/compile/logs/stdio

..\..\third_party\cld_2\src\internal\offsetmap.cc(82,43) :  warning(clang): format
specifies type 'long' but the argument has type 'size_type' (aka 'unsigned int') [-Wformat]
  fprintf(fout, "Offsetmap: %ld bytes\n", diffs_.size());
                            ~~~           ^~~~~~~~~~~~~
                            %u

There's no great portable way to printf size_t types. Since this is debugging code,
I suggest this patch:

Nicos-MacBook-Pro:src thakis$ svn diff
Index: internal/offsetmap.cc
===================================================================
--- internal/offsetmap.cc   (revision 165)
+++ internal/offsetmap.cc   (working copy)
@@ -79,7 +79,8 @@
   }

   Flush();    // Make sure any pending entry gets printed
-  fprintf(fout, "Offsetmap: %ld bytes\n", diffs_.size());
+  fprintf(fout, "Offsetmap: %lu bytes\n",
+          static_cast<unsigned long>(diffs_.size()));
   for (int i = 0; i < static_cast<int>(diffs_.size()); ++i) {
     fprintf(fout, "%c%02d ", "&=+-"[OpPart(diffs_[i])], LenPart(diffs_[i]));
     if ((i % 20) == 19) {fprintf(fout, "\n");}

Can you land this, please?

Reported by thakis@chromium.org on 2014-08-18 14:24:33

@ghost ghost self-assigned this Jul 27, 2015
@ghost
Copy link
Author

ghost commented Jul 27, 2015

Committed as r167. For consistency with the for-loop immediately following, I stuck
with static_cast<int> and %d. This should fix your error, please confirm!

Index: offsetmap.cc
===================================================================
--- offsetmap.cc        (revision 166)
+++ offsetmap.cc        (working copy)
@@ -79,7 +79,7 @@
   }

   Flush();    // Make sure any pending entry gets printed
-  fprintf(fout, "Offsetmap: %ld bytes\n", diffs_.size());
+  fprintf(fout, "Offsetmap: %d bytes\n", static_cast<int>(diffs_.size()));
   for (int i = 0; i < static_cast<int>(diffs_.size()); ++i) {
     fprintf(fout, "%c%02d ", "&=+-"[OpPart(diffs_[i])], LenPart(diffs_[i]));
     if ((i % 20) == 19) {fprintf(fout, "\n");}

Reported by andrewhayden@google.com on 2014-08-19 09:18:37

  • Status changed: Fixed

@ghost
Copy link
Author

ghost commented Jul 27, 2015

That was fast, thanks!

Reported by thakis@chromium.org on 2014-08-19 15:21:41

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants