[cfe-dev] Option to disable POD check for variadic functions

Douglas Gregor dgregor at apple.com
Sat May 21 09:34:23 PDT 2011


On May 19, 2011, at 3:15 PM, Tomasz Dabrowski wrote:

> Hello,
> 
> is it possible to disable POD check for variadic functions? For example:
> 
> error: cannot pass object of non-POD type 'string' through variadic
> function; call will abort at runtime [-Wnon-pod-varargs]
> for:
> struct string { const char * str; string() {}; };
> string s;
> printf("%s", s);
> 
> POD definition was updated (relaxed) in C++0x:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2294.html
> but it seems that Clang doesn't support this yet even in C++0x mode.

Fixed in Clang r131792.

> Microsoft's compiler ignores POD check, GCC in "regular" C++ behaves
> similar to Clang up to version 4.5. GCC in C++0x mode or GCC >= 4.5
> accepts such code.
> "Diagnostics that used to complain about passing non-POD types to ...
> or jumping past the declaration of a non-POD variable now check for
> triviality rather than PODness, as per C++0x."
> Possibility to ignore POD check would be very helpful.


Actually, the ability to disable the check is already in Clang, and the clue is right there in the diagnostic text: the [-Wnon-pod-varargs] at the end of the error tells you which warning flag controls this warning. So, pass -Wno-error=non-pod-varargs to downgrade it to a warning, or -Wno-non-pod-varargs to turn off the warning/error completely.

	- Doug



More information about the cfe-dev mailing list