http://llvm.org/bugs/show_bug.cgi?id=15768
Bug ID: 15768
Summary: [-cxx-abi microsoft] __cdecl methods returning
structures misbehave
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
----------------
$ cat cl.cpp
extern "C" int printf(const char *fmt, ...);
struct S {
int a, b, c;
};
struct This {
S __cdecl foo(S x);
int field;
};
int main(void) {
This obj;
obj.field = 13;
S arg;
arg.a = 99;
S s = obj.foo(arg);
printf("obj.field = %d\n", obj.field);
return 0;
}
----------------
$ cat clang.cpp
extern "C" int printf(const char *fmt, ...);
struct S {
int a, b, c;
};
struct This {
S __cdecl foo(S x);
int field;
};
S __cdecl This::foo(S x) {
S ret;
ret.a = 42;
printf("field = %d, x.a = %d\n", field, x.a);
field = 77;
return ret;
}
----------------
$ cl cl.cpp clang.cpp && ./cl.exe
field = 13, x.a = 99
obj.field = 77
----------------
$ clang -Xclang -cxx-abi -Xclang microsoft clang.cpp -c && \
cl -nologo -c cl.cpp && link clang.o cl.obj && ./clang.exe
field = -2, x.a = 99
obj.field = 42
(As of Clang r179681)
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs