The expression &ptr->fld not an dereference, instead it should be considered as (uint32_t)ptr + offsetof (ptr, fld) . I'm sure GCC makes this simplification, but I cannot find where in the code.
The above ends up as ADDR_EXPR(COMPONENT_REF (INDIRECT_REF (ptr), fld)) in AST, but at some point it should go through and simplify it. Having looked at almost all cases of ADDR_EXPR, COMPONENT_REF and INDIRECT_REF in the gcc tree, I find it hard to find where. Any ideas?
Please note that I tried to find help from the GCC people. In general, they are pretty worthless, but people here may know the answer. If this is a bad question, I will understand if it will be closed.
source share