<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - va_arg() with type 'id' produces incorrect output"
href="https://bugs.llvm.org/show_bug.cgi?id=47921">47921</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>va_arg() with type 'id' produces incorrect output
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>OpenBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>compile-fail
</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>anthonyc@gmx.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24084" name="attach_24084" title="This reproduces the bug, compile with -DUSE_HACK to apply the workaround mentioned.">attachment 24084</a> <a href="attachment.cgi?id=24084&action=edit" title="This reproduces the bug, compile with -DUSE_HACK to apply the workaround mentioned.">[details]</a></span>
This reproduces the bug, compile with -DUSE_HACK to apply the workaround
mentioned.
When I use va_arg, providing type 'id', the return values are incorrect.
In the source code I have attached, I have a function taking a variable number
of arguments of type 'id', I pass in 3 arguments, and return the third out of
it. The value of this third agument returned should be equal to the third
argument passed in. However it is not.
When I instead change the type passed to va_arg() to 'void*', (I guess this
works as they're both the same size?), I get the expected result.
I've tried to boil my example code down to demonstrate it as simple as
possible, however this behavior is present when I try to use the GNUstep system
too, and indeed the 'fix' of replacing occurances of va_arg(*, id) with
va_arg(*, void*) results in a completely stable system.
Here's an example shell session using the code I have attached:
netty$ cc bug.m -o bug
netty$ ./bug
netty$ echo $?
1
netty$ cc -DUSE_HACK bug.m -o bug
netty$ ./bug
netty$ echo $?
0
netty$ cc -v
OpenBSD clang version 8.0.1 (tags/RELEASE_801/final) (based on LLVM 8.0.1)
Target: powerpc-unknown-openbsd6.7
Thread model: posix
InstalledDir: /usr/bin
netty$ uname -a
OpenBSD netty.my.domain 6.7 GENERIC#714 macppc</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>