Add macros for diagnostic control, use for scanf %a tests
Joseph Myers
joseph@codesourcery.com
Wed Nov 26 02:09:00 GMT 2014
On Wed, 26 Nov 2014, Paul Eggert wrote:
> Joseph Myers wrote:
> > it doesn't work to have the pragmas in the same macro as the code
>
> Then how about using an inline function instead of a macro? Something like
> this:
>
> static inline __attribute__ ((__always_inline__)) int
> C99_sscanf (char const *str, char const *format, ...)
> {
> return sscanf (str, format, __builtin_va_arg_pack ());
> }
I'm doubtful about hiding warnings in ways that rely on the compiler not
being smart enough to see through them - it would be perfectly reasonable
for the compiler to warn in this case by doing format checking after
optimization. Warnings should be disabled in ways that clearly make it
incorrect for the compiler to warn.
> Similarly, if we're worried about fread_unlocked complaining about a
> zero-sized argument, perhaps we can write an inline wrapper for it; that
> should silence thw warning more accurately.
An inline wrapper would not be appropriate; these tests are specifically
using arguments with side-effects, and arguments with unusual types, to
verify that those work with the macro definitions the same way as they
would work with a normal function call (i.e. they are evaluated at least
once, and the floating-point arguments are converted to the correct
argument types). Using an inline wrapper would defect this testing.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list