<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 --- - va_arg error on a trivially copyable class"
href="http://llvm.org/bugs/show_bug.cgi?id=20667">20667</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>va_arg error on a trivially copyable class
</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>Linux
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>msebor@gmail.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>Based on my reading of paragraph 7 of 5.2.2 of C++ 11, an object of a type with
a trivial copy and move constructors and destructor can be passed as an
argument to a function declared with the ellipsis that has no corresponding
parameter for it (i.e., the class is not required to be a POD type as it did
prior to C++ 11). For example, the program below is well-defined, but Clang
rejects it. GCC 4.8.2 accepts the code as I would expect.
$ cat x.cpp && ./llvm-head-gcc-4.8.2-x86_64-linux/Debug+Asserts/bin/clang -Wall
-std=c++11 -fsyntax-only x.cpp
#include <stdarg.h>
struct S { S (int); };
S f (int a, ...) {
va_list va;
va_start (va, a);
S s = va_arg (va, S);
va_end (va);
return s;
}
S g () {
return f (0, S (1));
}
x.cpp:8:27: error: second argument to 'va_arg' is of non-POD type 'S'
[-Wnon-pod-varargs]
S s = va_arg (va, S);
^
/scratch/msebor/llvm/llvm-head-gcc-4.8.2-x86_64-linux/Debug+Asserts/bin/../lib/clang/3.5.0/include/stdarg.h:35:50:
note:
expanded from macro 'va_arg'
#define va_arg(ap, type) __builtin_va_arg(ap, type)
^
1 error generated.</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>