


If you just create a pointer to incompatible types, everything is fine. What the reader was worried about is that since ‘measurements_t’ and ‘uncopied_memory’ are by no means compatible, wouldn’t a cast to an ‘uncopied_memory’ pointer constitute a violation of the “ strict aliasing rule“?Īctually, when it comes to the “strict aliasing rule,” the fact that these structs have incompatible members doesn’t really matter-even if you accessed the stored value through a pointer to a struct with an identical set of members you would be in trouble if the tag names of the structs are different, it already counts as a violation of the “strict aliasing rule.” Temporary materialization, however, is (formally) performed for prvalue arguments: the program is ill-formed if the argument is not destructible.But back to the question. Lvalue-to-rvalue, array-to-pointer, or function-to-pointer conversions are not performed.

When applied to an expression, sizeof does not evaluate the expression, and even if the expression designates a polymorphic object, the result is the size of the static type of the expression. The result of sizeof is always nonzero, even if applied to an empty class type. The number of bytes occupied by a potentially-overlapping subobject may be less than the size of that object. When applied to a class type, the result is the number of bytes occupied by a complete object of that class, including any additional padding required to place such object in an array. When applied to a reference type, the result is the size of the referenced type. Sizeof cannot be used with function types, incomplete types, or bit-field glvalues. The following sizeof expressions always evaluate to 1:

Notesĭepending on the computer architecture, a byte may consist of 8 or more bits, the exact number being recorded in CHAR_BIT. Member access operators: a, *a, &a, a->b, a.b, a->*b, a.*bĢ) Yields the size in bytes of the object representation of the type of expression, if that expression is evaluated. Increment and decrement: ++a, -a, a++, a. Value categories (lvalue, rvalue, xvalue)Ĭharacter literals including escape sequencesĪ=b, a+=b, a-=b, a*=b, a/=b, a%=b, a&=b, a|=b, a^=b, a>=b
