title: Is this use of union well defined?
body: <p>Consider the following code:</p>
  
  <pre><code>union
  {
      PrStatus_X86_64 prstat64;
      PrStatus_X86    prstat32;
  } prstat;
  
  iovec prstat_iov = {&amp;prstat, sizeof prstat};
  
  if(ptrace(PTRACE_GETREGSET, tid, NT_PRSTATUS, &amp;prstat_iov) != -1)
  {
      if(prstat_iov.iov_len==sizeof prstat.prstat64)
          use(prstat.prstat64);
      else if(prstat_iov.iov_len==sizeof prstat.prstat32)
          use(prstat.prstat32);
  }
  </code></pre>
  
  <p>Here, depending on what the <code>ptrace</code> call returns as the resulting <code>prstat_iov.iov_len</code>, <code>prstat</code> should be interpreted either as one structure, or as another one.</p>
  
  <p>As is well known, in C++ unions can't be used as freely as in C, namely, reading an inactive member of a union results in undefined behavior. But can we consider that the <code>ptrace</code> call in the above code will actually act as "writing to the correct member" of the union, according to the C++ Standard, so that the above code would have well-defined behavior?</p>