GCC Translation Validation Part 4: Address calculations
In this article, Krister Walfridsson explains the implementation of pysmtgcc and focuses on address calculations in GIMPLE, a representation used by GCC. Address calculations in GIMPLE can be done using ARRAY_REF and COMPONENT_REF, which are used for indexing into arrays and structures. The behavior is undefined if the ARRAY_REF index is outside the accessed object when dereferencing an element. However, it is allowed to take the address of the element "one past" the array.
The article also discusses the handling of flexible arrays, which are arrays at the end of structures that may be declared without a size. pysmtgcc limits the indexing by the memory block size in this case.
The author raises concerns about the correct GIMPLE semantics for pointer arithmetic and how it handles moving a pointer from one object to another. The current implementation treats the use of COMPONENT_REF and ARRAY_REF as undefined behavior if the whole object does not fit in the available memory.
For developers interested in GCC and GIMPLE, this article provides valuable insights into the implementation details of address calculations and the challenges involved.