Passing NON-POD type to Variadic function is undef

2019-01-15 18:52发布

问题:

In this document, the author said

Only a POD-type can be an argument for the ellipsis "..." while std::string is not a POD-type.

I'm understanding this as Passing NON-POD type to Variadic function is undefined behavior. Is it right?
Though, is he saying C/C++ standard? I tried to find it at n3242 C++ spec. But can not find.

I'd like to know I'm understanding rightly and this is a standard.

回答1:

It's specified in 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.

So it's up to each compiler whether to support it or not; portable code can't rely on any implementation defined behaviour. In older standards, it was simply undefined.