Closed
Bug 1256558
Opened 9 years ago
Closed 9 years ago
parser/expat/lib/xmlparse.c(2604): warning C4311: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
Categories
(Core :: XML, defect)
Core
XML
Tracking
()
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: gps, Assigned: gps)
References
Details
Attachments
(1 file, 1 obsolete file)
Seeing multiple compilation warnings converted to errors when building on Visual Studio 2015 Update 1 in automation.
22:46:35 INFO - xmlparse.c
22:46:35 INFO - c:/builds/moz2_slave/try-w64-0000000000000000000000/build/src/parser/expat/lib/xmlparse.c(2604): error C2220: warning treated as error - no 'object' file generated
22:46:35 INFO - Warning: C4311 in c:\builds\moz2_slave\try-w64-0000000000000000000000\build\src\parser\expat\lib\xmlparse.c: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - c:/builds/moz2_slave/try-w64-0000000000000000000000/build/src/parser/expat/lib/xmlparse.c(2604): warning C4311: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - Warning: C4311 in c:\builds\moz2_slave\try-w64-0000000000000000000000\build\src\parser\expat\lib\xmlparse.c: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - c:/builds/moz2_slave/try-w64-0000000000000000000000/build/src/parser/expat/lib/xmlparse.c(2632): warning C4311: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - Warning: C4311 in c:\builds\moz2_slave\try-w64-0000000000000000000000\build\src\parser\expat\lib\xmlparse.c: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - c:/builds/moz2_slave/try-w64-0000000000000000000000/build/src/parser/expat/lib/xmlparse.c(3294): warning C4311: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - Warning: C4311 in c:\builds\moz2_slave\try-w64-0000000000000000000000\build\src\parser\expat\lib\xmlparse.c: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - c:/builds/moz2_slave/try-w64-0000000000000000000000/build/src/parser/expat/lib/xmlparse.c(5376): warning C4311: 'type cast': pointer truncation from 'const char *' to 'unsigned long'
22:46:35 INFO - c:/builds/moz2_slave/try-w64-0000000000000000000000/build/src/config/rules.mk:891: recipe for target 'xmlparse.obj' failed
Assignee | ||
Comment 1•9 years ago
|
||
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/39995/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39995/
Attachment #8730558 -
Flags: review?(peterv)
Comment 2•9 years ago
|
||
This is presumably coming from [1]:
> #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1))
My understanding is we always convert to UTF-16 prior to handing off to libexpat, so the first part would be true, and we'll hit the second. I have no idea what the goal of the second part is...I guess it's checking pointer alignment to determine if it needs to skip a byte? If that's the case, again it's probably harmless as it's testing the lowest bit, so truncation shouldn't be an issue.
[1] https://dxr.mozilla.org/mozilla-central/rev/d6ee82b9a74155b6bfd544166f036fc572ae8c56/parser/expat/lib/xmlparse.c#29
Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8730558 [details]
MozReview Request: Bug 1256558 - Disable C4311 to unblock compilation on VS2015; r?peterv
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39995/diff/1-2/
Comment 4•9 years ago
|
||
Trunk expat has
/* Using pointer subtraction to convert to integer type. */
#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
Does that solve the warning? We could just cherrypick that.
Updated•9 years ago
|
Flags: needinfo?(gps)
Assignee | ||
Comment 5•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=446b041868bd should have results in <1 hr.
Flags: needinfo?(gps)
Assignee | ||
Comment 6•9 years ago
|
||
The Try push looks happy.
Assignee | ||
Comment 7•9 years ago
|
||
This code is cherry picked from the trunk version of expat.
Review commit: https://reviewboard.mozilla.org/r/41487/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/41487/
Attachment #8732979 -
Flags: review?(peterv)
Assignee | ||
Updated•9 years ago
|
Attachment #8730558 -
Attachment is obsolete: true
Attachment #8730558 -
Flags: review?(peterv)
Comment on attachment 8732979 [details]
MozReview Request: Bug 1256558 - Change MUST_CONVERT to avoid C4311 in VS2015; r?peterv
https://reviewboard.mozilla.org/r/41487/#review37989
Attachment #8732979 -
Flags: review+
Assignee | ||
Updated•9 years ago
|
Attachment #8732979 -
Flags: review?(peterv)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → gps
Status: NEW → ASSIGNED
Comment 10•9 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in
before you can comment on or make changes to this bug.
Description
•