[llvm-bugs] [Bug 31002] New: clang rejects valid C++ code with variable argument function
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Nov 12 18:48:31 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31002
Bug ID: 31002
Summary: clang rejects valid C++ code with variable argument
function
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: su at cs.ucdavis.edu
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
It seems to affect all clang versions since at least as early as 3.2.x, and is
also incorrectly rejected by ICC.
Both GCC and MSVC correctly accept the code.
The code is accepted if the destructor is commented out.
$ clang++ -v
clang version 4.0.0 (trunk 286715)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ g++-6.2 small.cpp
$
$ clang++ small.cpp
small.cpp:12:20: error: second argument to 'va_arg' is of non-POD type 'A'
[-Wnon-pod-varargs]
A v = va_arg (a, A);
^
/usr/local/clang-trunk/bin/../lib/clang/4.0.0/include/stdarg.h:35:50: note:
expanded from macro 'va_arg'
#define va_arg(ap, type) __builtin_va_arg(ap, type)
^~~~
small.cpp:19:11: error: cannot pass object of non-POD type 'A' through variadic
function; call will abort at runtime
[-Wnon-pod-varargs]
foo (t, t);
^
2 errors generated.
$
----------------------------
#include <cstdarg>
struct A
{
virtual ~A () {}
};
void foo (A p, ...)
{
va_list a;
va_start (a, p);
A v = va_arg (a, A);
va_end (a);
}
int main ()
{
A t;
foo (t, t);
return 0;
}
--
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/20161113/a3204e46/attachment.html>
More information about the llvm-bugs
mailing list