title: Struct argument passed in pthread create gets mangled
body: <p>I have a structure named command that looks like this. The first value in the enum is AND_COMMAND</p>
  
  <pre><code>struct command
  {
    enum command_type type;
    int status;
    char *input;
    char *output;
    union
    {
      struct command *command[2];
      char **word;
      struct command *subshell_command;
    } u;
  };
  </code></pre>
  
  <p>When I call pthread_create I pass it a command in the form of a command_t (that is cast to (void *)).</p>
  
  <pre><code>typedef struct command *command_t;
  </code></pre>
  
  <p>My thread takes this (void *) command_t, casts it back (command_t) and tries to use the structure. </p>
  
  <pre><code>void execute_thread(void *c) {
    command_t command = (command_t) c;
  </code></pre>
  
  <p>However when I pass a struct in to execute_thread the first values are zeroed out. If I have a command_type of SIMPLE_COMMAND and status of -1, when it's passed in to the thread the command_type is AND_COMMAND and status of 0. None of the other values in the struct are changed however. What's more curious is when this data mangling occurs. I was able to capture the phenomenon in gdb: </p>
  
  <pre><code>445   command_t command = (command_t) c;
  (gdb) p *((command_t) c)
  $6 = {type = SIMPLE_COMMAND, status = -1, input = 0x605370 "abc", output = 0x605390 "def", u = {
  command = {0x6052e0, 0x0}, word = 0x6052e0, subshell_command = 0x6052e0}}
  (gdb) n
  (gdb) p *((command_t) c)
  $7 = {type = AND_COMMAND, status = 0, input = 0x605370 "abc", output = 0x605390 "def", u = {command = {
    0x6052e0, 0x0}, word = 0x6052e0, subshell_command = 0x6052e0}}
  </code></pre>
  
  <p>It appears that the structure pointed to by c doesn't change until casting it with <code>(command_t) c;</code> I am entirely confounded by this behavior. I didn't think that casting a pointer could change the values it pointed to. Could someone please point out, ha ha, what could be going on here? I would appreciate that very much. </p>