[Lldb-commits] [PATCH] D29256: Do not pass non-POD type variables through variadic function
Ilia K via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 30 03:06:46 PST 2017
ki.stfu added a comment.
In https://reviews.llvm.org/D29256#660159, @krytarowski wrote:
> It's undefined (implementation defined) behavior.
>
> C++11 5.2.2/7:
>
>
> > Passing a potentially-evaluated argument of class type having a non-trivial copy constructor, a non-trivial move contructor, or a non-trivial destructor, with no corresponding parameter, is conditionally-supported with implementation-defined semantics.
> >
Interesting. Passing to what? I thought it means we shouldn't pass non-trivial types through variadic arguments (`...` expression), and in this case we don't do it because `CMIUtilString` is the type of the parameter `vFormating` which has a name.
Unfortunately I can't reproduce it on my Ubuntu using the following example:
#include <cstdarg>
#include <iostream>
struct Count {
int value;
explicit Count(int v) : value(v) { }
// Make it non-trivial
Count(const Count&) : value(0) { }
Count(Count&&) : value(0) { }
~Count() { if (value) value |= 1; }
};
int add_nums(Count count, ...)
{
int result = 0;
va_list args;
va_start(args, count);
for (int i = 0; i < count.value; ++i) {
result += va_arg(args, int);
}
va_end(args);
return result;
}
int main()
{
std::cout << add_nums(Count(4), 25, 25, 50, 50) << '\n';
return 0;
}
> This patch was created to address compiler warning.
Could you tell me what compiler and platform do you use and provide the exact warning message?
Repository:
rL LLVM
https://reviews.llvm.org/D29256
More information about the lldb-commits
mailing list