casting - Which C++ cast type is a C cast equivalent to -
i guessing c reinterpret cast , bit pattern left is.
i trying understand happen when cast wider signed value narrower signed value. sign preserved, or values in narrower width intepreted signed value.
thanks assistance.
edit--this c99 compiled c code. question isn't c++ compiler sloppy old style cast, rather if there defined c does.
you don't need ask c++ if care c, in example c++ , c still same thing;
c++ says of these integral conversions:
if destination type signed, value unchanged if can represented in destination type (and bit-field width); otherwise, value implementation-defined.
c99 says of these integral conversion:
otherwise, new type signed , value cannot represented in it; either result implementation-defined or implementation-defined signal raised.
casting larger integral value smaller, signed integral value produce same value if possible , give implementation defined (i.e., non-portable) behavior otherwise.
§ 5.4/4 states
the conversions performed by
- a const_cast (5.2.11),
- a static_cast (5.2.9),
- a static_cast followed const_cast,
- a reinterpret_cast (5.2.10), or
- a reinterpret_cast followed const_cast,
can performed using cast notation of explicit type conversion.
[...]
if conversion can interpreted in more 1 of ways listed above, interpretation appears first in list used, if cast resulting interpretation ill-formed.
c++ defined such compatible c; is, c casts same thing in c++ in c. means cast notation in c in fact different things based on types being cast between.
Comments
Post a Comment