Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing NON-POD type to Variadic function is undefined behavior?

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.

like image 337
Benjamin Avatar asked Apr 10 '12 06:04

Benjamin


1 Answers

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.

like image 197
Mike Seymour Avatar answered Sep 21 '22 13:09

Mike Seymour