Implicit conversions

Implicit conversions are performed whenever an expression of some type T1 is used in context that does not accept that type, but accepts some other type T2; in particular:

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 170C++98the behavior of pointer-to-member conversions was unclearif the derived class does not have the original membermade clear
CWG 172C++98enumeration type was promoted based on its underlying typebased on its value range instead
CWG 330(N4261)C++98the conversion from double* const (*p)[3]to double const * const (*p)[3] was invalidmade valid
CWG 519C++98null pointer values were not guaranteed to bepreserved when converting to another pointer typealways preserved
CWG 616C++98the behavior of lvalue to rvalue conversion ofany uninitialized object and pointer objectsof invalid values was always undefinedindeterminate unsigned charis allowed; use of invalid pointersis implementation-defined
CWG 685C++98the underlying type of an enumeration type wasnot prioritized in integral promotion if it is fixedprioritized
CWG 707C++98integer to floating point conversionhad defined behavior in all casesthe behavior is undefined ifthe value being converted isout of the destination range
CWG 1423C++11std::nullptr_t was convertible to boolin both direct- and copy-initializationdirect-initialization only
CWG 1773C++11a name expression that appears in a potentially-evaluatedexpression such that the object named is not odr-used mightstill be evaluated during an lvalue-to-rvalue conversionnot evaluated
CWG 1781C++11std::nullptr_t to bool was considered an implicitconversion even though it is only valid for direct-initializationno longer consideredan implicit conversion
CWG 1787C++98the behavior of reading from an indeterminateunsigned char cached in a register was undefinedmade well-defined
CWG 1981C++11contextual conversions considered explicit conversion functionsnot considered
CWG 2140C++11it was unclear whether lvalue-to-rvalue conversions fromstd::nullptr_t lvalues fetch these lvalues from memorynot fetched
CWG 2310C++98for derived-to-base pointer conversions andbase-to-derived pointer-to-member conversions,the derived class type could be incompletemust be complete
CWG 2484C++20char8_t and char16_t had different integralpromotion strategies, but they can fit both of themchar8_t should be promotedin the same way as char16_t
CWG 2485C++98integral promotions involving bit-fields were not specified wellimproved the specification
CWG 2813C++23temporary materialization would occur when an explicitobject member function of a class prvalue is invokedwill not occurin this case
CWG 2861C++98a pointer to a type-inaccessible object could beconverted a pointer to a base class subobjectthe behavior isundefined in this case
CWG 2879C++17temporary materialization conversion was applied on prvalueas an operand of an operator that expects glvaluenot applied in some cases
CWG 2899C++98lvalue-to-rvalue conversions could be applied to lvaluesdesignating objects with invalid value representationsthe behavior isundefined in this case
CWG 2901C++98the result of lvalue-to-rvalue conversion from an unsigned intlvalue referring to an int object with value -1 was unclearmade clear

# See also