Option to disable POD check for variadic functions

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.

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.

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.

Please file a bug at http://llvm.org/bugs/

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.

It makes sense to model the semantics properly for C++0x; I don't see any specific reason to disable this check.

  - Doug

Francois might want to - I think MFC"s CString was modeled carefully so that passing it to printf would do the right thing, and I suspect there’s quite a bit of code relying on this out there.

Sebastian

Will passing the inverse of the noted flag (i.e. -Wno-non-pod-varargs) not work?

Sean

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

Yes, but this only hides error/warning, doesn't make actual vararg
call work. I'll check trunk version, thanks for update.

The vararg call isn't going to work, because it can't. Now, there's still a bug here---we should be generating a __builtin_trap in this case---but passing non-POD/non-trivial types through varags is undefined behavior, for which we generally trap.

  - Doug