Closed Bug 1257410 Opened 8 years ago Closed 8 years ago

xpcom/tests/windows/TestCOM.cpp(57): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'nsrefcnt'

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: gps, Assigned: gps)

References

Details

Attachments

(1 file)

The C4477 warning is being enabled in bug 1124033 and occurs twice in TestCOM.cpp. When building with warnings as errors with VS2015u1, this causes build failure and thus blocks the transition to VS2015.

xpcom/tests/windows/TestCOM.cpp(57): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'nsrefcnt'
xpcom/tests/windows/TestCOM.cpp(57): 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
xpcom/tests/windows/TestCOM.cpp(57): note: consider using '%lld' in the format string
xpcom/tests/windows/TestCOM.cpp(57): note: consider using '%Id' in the format string
xpcom/tests/windows/TestCOM.cpp(57): note: consider using '%I64d' in the format string
xpcom/tests/windows/TestCOM.cpp(65): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'nsrefcnt'
xpcom/tests/windows/TestCOM.cpp(65): 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
xpcom/tests/windows/TestCOM.cpp(65): note: consider using '%lld' in the format string
xpcom/tests/windows/TestCOM.cpp(65): note: consider using '%Id' in the format string
xpcom/tests/windows/TestCOM.cpp(65): note: consider using '%I64d' in the format string
nsrefcnt is a uintptr_t. We could probably just use %p here. Hex vs. decimal shouldn't actually matter here and that'll make it the right size on 32 and 64 bit.
Comment on attachment 8733014 [details]
MozReview Request: Bug 1257410 - Use %p and cast in printf to avoid C4477 on VS2015; r?khuey

https://reviewboard.mozilla.org/r/41511/#review37943
Attachment #8733014 - Flags: review?(khuey) → review+
Try was not amused:

 13:44:03     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/xpcom/tests/windows/TestCOM.cpp(57): error C2220: warning treated as error - no 'object' file generated
 13:44:03     INFO -  Warning: C4477 in c:\builds\moz2_slave\try-w64-d-00000000000000000000\build\src\xpcom\tests\windows\TestCOM.cpp: 'printf' : format string '%p' requires an argument of type 'void *', but variadic argument 1 has type 'nsrefcnt'
 13:44:03     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/xpcom/tests/windows/TestCOM.cpp(57): warning C4477: 'printf' : format string '%p' requires an argument of type 'void *', but variadic argument 1 has type 'nsrefcnt'
 13:44:03     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/xpcom/tests/windows/TestCOM.cpp(57): 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
 13:44:03     INFO -  Warning: C4477 in c:\builds\moz2_slave\try-w64-d-00000000000000000000\build\src\xpcom\tests\windows\TestCOM.cpp: 'printf' : format string '%p' requires an argument of type 'void *', but variadic argument 1 has type 'nsrefcnt'
 13:44:03     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/xpcom/tests/windows/TestCOM.cpp(65): warning C4477: 'printf' : format string '%p' requires an argument of type 'void *', but variadic argument 1 has type 'nsrefcnt'
 13:44:03     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/xpcom/tests/windows/TestCOM.cpp(65): 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
 13:44:03     INFO -  c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/obj-firefox/_virtualenv/Scripts/python.exe c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/config/nsinstall.py -t -m 644 'testcompnoaslr.dll' '../../../_tests/xpcshell/xpcom/tests/unit/components'
13:44:03 INFO - c:/builds/moz2_slave/try-w64-d-00000000000000000000/build/src/config/rules.mk:918: recipe for target 'TestCOM.obj' failed
You can cast to void* then to use %p.
Comment on attachment 8733014 [details]
MozReview Request: Bug 1257410 - Use %p and cast in printf to avoid C4477 on VS2015; r?khuey

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/41511/diff/1-2/
Attachment #8733014 - Attachment description: MozReview Request: Bug 1257410 - Use %p in printf to avoid C4477 on VS2015; r?khuey → MozReview Request: Bug 1257410 - Use %p and cast in printf to avoid C4477 on VS2015; r?khuey
Assignee: nobody → gps
Status: NEW → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/cdf79a0b9a3b
Status: ASSIGNED → 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.