Closed Bug 1256559 Opened 8 years ago Closed 8 years ago

intl/locale/windows/nsWin32Locale.cpp(736): warning C4477: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'size_t'

Categories

(Core :: Internationalization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: gps, Assigned: smontagu)

References

Details

Attachments

(1 file, 3 obsolete files)

Seeing multiple compiler warnings turned into errors when running Visual Studio 2015 Update 1 in automation.

 22:58:57     INFO -  nsWin32Locale.cpp
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): error C2220: warning treated as error - no 'object' file generated
 22:58:57     INFO -  Warning: C4477 in c:\builds\moz2_slave\try-w64-d-00000000000000000000\build\src\intl\locale\windows\nsWin32Locale.cpp: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'size_t'
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): warning C4477: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'size_t'
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): note: consider using '%zd' in the format string
 22:58:57     INFO -  Warning: C4477 in c:\builds\moz2_slave\try-w64-d-00000000000000000000\build\src\intl\locale\windows\nsWin32Locale.cpp: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 2 has type 'size_t'
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): warning C4477: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 2 has type 'size_t'
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(736): note: consider using '%zd' in the format string
 22:58:57     INFO -  Warning: C4477 in c:\builds\moz2_slave\try-w64-d-00000000000000000000\build\src\intl\locale\windows\nsWin32Locale.cpp: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'size_t'
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(740): warning C4477: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'size_t'
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(740): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 22:58:57     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/intl/locale/windows/nsWin32Locale.cpp(740): note: consider using '%zd' in the format string
22:58:57 INFO - c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/config/rules.mk:930: recipe for target 'nsWin32Locale.obj' failed
As part of unblocking building with VS2015u1 in automation, I'm mass
disabling compiler warnings that are turned into errors. This is not
the preferred mechanism to fix compilation warnings. So hopefully
this patch never lands because someone insists on fixing the underlying
problem instead. But if it does land, hopefully the workaround is
only temporary.

Review commit: https://reviewboard.mozilla.org/r/39999/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39999/
Attachment #8730560 - Flags: review?(smontagu)
Comment on attachment 8730560 [details]
MozReview Request: Bug 1256559 - Disable C4477 to unblock compilation on VS2015; r?smontagu

https://reviewboard.mozilla.org/r/39999/#review36775
Attachment #8730560 - Flags: review?(smontagu) → review+
I can't easily compile on Windows, but shouldn't this be enough to prevent the warning?
Attachment #8730945 - Flags: review?(gps)
Comment on attachment 8730945 [details] [diff] [review]
Remove the warning by using %zd like the man said

Review of attachment 8730945 [details] [diff] [review]:
-----------------------------------------------------------------

I haven't touched C++ in a very, very long time. So I'm not appropriate to review this.

But I can push this patch to Try and let you know if it works.
Comment on attachment 8730945 [details] [diff] [review]
Remove the warning by using %zd like the man said

Review of attachment 8730945 [details] [diff] [review]:
-----------------------------------------------------------------

https://treeherder.mozilla.org/logviewer.html#?job_id=18126620&repo=try says this patch failed to clear the warning.
Attachment #8730945 - Flags: review?(gps) → review-
But it does remove two warnings, so this version should clear the third one.
Assignee: nobody → smontagu
Attachment #8730945 - Attachment is obsolete: true
Attachment #8731073 - Flags: feedback?(gps)
Comment on attachment 8731073 [details] [diff] [review]
Remove the warning by using %zd like the man said ,v.2

Review of attachment 8731073 [details] [diff] [review]:
-----------------------------------------------------------------

This seems to have eliminated the warnings!

I'll drop my review requests. Please get review and land this ASAP to unblock VS2015.

Thank you for insisting on the proper fix.
Attachment #8731073 - Flags: feedback?(gps) → feedback+
Attachment #8730560 - Attachment is obsolete: true
Attachment #8731073 - Flags: review?(jfkthame)
Comment on attachment 8731073 [details] [diff] [review]
Remove the warning by using %zd like the man said ,v.2

Review of attachment 8731073 [details] [diff] [review]:
-----------------------------------------------------------------

Does this work on VS2013? AFAICT, it probably won't...

https://connect.microsoft.com/VisualStudio/feedback/details/806338/vc-printf-and-scanf-should-support-z

So are we totally dropping VS2013 support at this point? If not, we need an alternative solution. (Given where this is being used, I'd think that just casting the size_t to an unsigned int and printing it with %u would be fine.)
I'm not sure when we're dropping VS2013. But I know people are anxious to do that so we can adopt more modern C++ features.

Code will need to work with both VS2013 and VS2015 for the interim. Or you can disable the warning.
This should avoid the warnings, while remaining compatible with older VS releases (lacking %z). The numbers involved here will never be large enough to exceed a plain 'unsigned' value.
Attachment #8732815 - Flags: review?(smontagu)
Attachment #8731073 - Attachment is obsolete: true
Attachment #8731073 - Flags: review?(jfkthame)
https://hg.mozilla.org/mozilla-central/rev/521e461d2eef
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.