It is a common strategy in C to cast one type to another type, relying on the fact that the layout of a C struct has certain guarantees. Libraries such as GLib rely on this to implement object-oriented like inheritance. Basically:
struct Base
{
  int x;
  int y;
};
struct Derived
{
  struct Base b;
  int z;
};
This enables a Base* pointer to be assigned to the address of a Derived object.
But I'm also aware of the "strict aliasing" rule, which is the implicit assumption by the compiler that different-type pointers can't point to the same address. (This enables the compiler to perform certain optimizations.)
So, how are these two things reconciled?  Many C libraries, include Glib, CPython, etc., use the above strategy to cast between types.  Are they all simply compiling with flags like no-strict-aliasing?
 
     
    