This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add macros for diagnostic control, use for scanf %a tests


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]