This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH]: Fix PR tree-optimization/21407
I don't think life is that good.
I think that the "what is an object" concerns apply in C++ too. Though
you don't have "offsetof" for non-PODs, nothing says you can't just
*know* the offset and use it in the exact same way. I really don't
think we can language-lawyer our away arounad the issues here; there is
no clear answer in the standard at this point. We have to choose
You do not need language lawyering for that. You can still provide a
switch, but it could/should enable the optimization for C++ by default.
You would need reinterpret_cast, the standard says at
[expr.reinterpret.cast] that arithmetic tricks on pointers are
outlawed, for both reinterpret_casts to integral or pointer types:
A value of integral type or enumeration type can be explicitly
converted to a pointer. A pointer converted to an integer of
sufficient size and back to the same pointer type will have its
original value; mappings between pointers and integers are otherwise
A pointer to an object can be explicitly converted to a pointer to an
object of different type. Except that converting an rvalue of type
"pointer to T1" to the type "pointer to T2" (where T1 and T2 are
object types and where the alignment requirements of T2 are no
stricter than those of T1) and back to its original type yields the
original pointer value, the result of such a pointer conversion is