[LLVMbugs] [Bug 15556] New: [Windows] Returning structures from functions has wrong ABI

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 20 16:55:03 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15556

            Bug ID: 15556
           Summary: [Windows] Returning structures from functions has
                    wrong ABI
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: timurrrr at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130320/70826ed0/attachment.html>


More information about the llvm-bugs mailing list