/* Test125.c
   Swinehart June 30, 1982  10:14 AM */

struct Str1 { int a, b, c, d; };
struct Str2 { int len; int type; struct Str1 entries[10]; };
struct Str3 { struct Str1 entries[10]; };

/* Double "loopholes" cause address arithmetic problems.  This particular
example comes up when one normally passes around a pointer to an embedded
structure, but occasionally wants to back up to the "encapsulation."  Knowing the
distance in words to back up, the method is to treat the original embedded pointer as an int*, adjust it, then recast it as the outer structure type. */
 
Test124()
  {
  struct Str3 *str3;
  struct Str2 *str2;
  int *temp;
/* Fails */
  str2 = (struct Str2 *) (((int *) str3)-2);
/* Succeeds */
  temp = ((int *) str3)-2;
  str2 = (struct Str2 *) temp;
  };