Object

C++ programs create, destroy, refer to, access, and manipulate objects.

# Notes

Objects in C++ have different meaning from objects in object-oriented programming (OOP):

In the defect report P0593R6, implicit object creation was considered happening when creating a byte array or invocating an allocation function (which is possibly user-defined and constexpr) during constant evaluation. However, such allowance caused indeterminism in constant evaluation which was undesired and uninplementable in some aspects. As a result, P2747R2 disallowed such implicit object creation in constant evaluation. We intentedly treat such change as a defect report although the whole paper is not.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 633C++98variables could only be objectsthey can also be references
CWG 734C++98it was unspecified whether variables definedin the same scope that are guaranteed to havethe same value can have the same addressaddress is guaranteed to bedifferent if their lifetimes overlap,regardless of their values
CWG 1189C++98two base class subobjects of the sametype could have the same addressthey always havedistinct addresses
CWG 1861C++98for oversize bit-fields of narrow charactertypes, all bits of the object representationstill participated in the value representationallows padding bits
CWG 2489C++98char[] cannot provide storage, but objectscould be implicitly created within its storageobjects cannot be implicitly createdwithin the storage of char[]
CWG 2519C++98the definition of object representation did not address bit-fieldsaddresses bit-fields
CWG 2719C++98the behavior of creating an objectin misaligned storage was unclearthe behavior isundefined in this case
CWG 2753C++11it was unclear whether a backing array of aninitializer list can share storage with a string literalthey can share storage
CWG 2795C++98when determining whether two objects with overlappinglifetimes can have the same address, if any of them is asubobject of zero size, they could have similar distinct typesonly allows non-similar types
P0593R6C++98previous object model did not support manyuseful idioms required by the standard libraryand was not compatible with effective types in Cimplicit object creation added

# See also