<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 --- - [-cxx-abi microsoft] __cdecl methods returning structures misbehave"
href="http://llvm.org/bugs/show_bug.cgi?id=15768">15768</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[-cxx-abi microsoft] __cdecl methods returning structures misbehave
</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>C++
</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>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>----------------
$ 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)</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>