[LLVMbugs] [Bug 20667] New: va_arg error on a trivially copyable class
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Aug 14 16:25:13 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20667
Bug ID: 20667
Summary: va_arg error on a trivially copyable class
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: msebor at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
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.
--
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/20140814/c0d4e8cb/attachment.html>
More information about the llvm-bugs
mailing list