[xsd-users] static_cast instead of reinterpret_cast in ace-cdr-stream-*.hxx

Ray Lischner rlischner at proteus-technologies.com
Fri Jan 19 11:52:00 EST 2007


The ACE CDR stream insertion and extraction headers use
reinterpret_cast<> when they should use static_cast<>. A comment in the
code says that reinterpret_cast is necessary because the cast might
discard a sign. The comment is wrong. Section 5.2.10 of the standard
lists the conversions that reinterpret_cast<> can perform, and X to
unsigned X is not one of them. Section 5.2.9 lists the conversions that
static_cast<> can perform, and any allowed type conversion is permitted.
Section 4.7 tells us that X to unsigned X is a permissible type
conversion. I attached a patch against 2.3.1.b2. The patch also applies
to 2.3.0. (I used an attachment because my mailer wraps lines, and I
can't find a way to turn it off.)
--
Ray Lischner

-------------- next part --------------
A non-text attachment was scrubbed...
Name: reinterpret_cast.patch
Type: application/octet-stream
Size: 1845 bytes
Desc: reinterpret_cast.patch
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070119/e1d7a448/reinterpret_cast.obj


More information about the xsd-users mailing list