<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [Windows] Returning structures from functions has wrong ABI"
   href="http://llvm.org/bugs/show_bug.cgi?id=15556">15556</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Windows] Returning structures from functions has wrong ABI
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>timurrrr@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Example:
----------------
$ cat cl.c
struct S {
  int a, b, c;
};

struct S foo(void);

int main(void) {
  struct S s = foo();
  if (s.a != 1)
    return 1;
  if (s.b != 2)
    return 2;
  if (s.c != 3)
    return 3;
  return 0;
}
----------------
int printf(const char *fmt, ...);

void do_something_complex(void) {
  printf("%d %d %d %d\n", 1, 2, 3, 4);
}

struct S {
  int a, b, c;
};

struct S foo(void) {
  struct S ret;
  ret.a = 1;
  ret.b = 2;
  ret.c = 3;
  do_something_complex();
  return ret;
}
----------------

$ cl cl.c clang.c && ./cl.exe; echo $?
-> works fine

As of r177589,
$ clang clang.c -c && cl -c cl.c && link clang.o cl.obj && ./clang.exe ; echo
$?
-> Segmentation Fault after the printf.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>