On 05/20/2015 09:40 PM, Paul Eggert wrote: > $EGREP has undefined behavior on binary data, so this isn't portable.
Bummer. It will work on mingw (which only uses GNU grep), which is the affected platform, but you're right that we have to make it not break other platforms. And 'strings' is not portable, as a way to filter down to non-binary data. > > I long ago gave up on AC_EGREP_CPP, since it's too flaky nowadays. Why > can't we test directly for what we're worried about? I'm afraid I am > not following why the value of PRIdMAX is related to whether printf > should use the __gnu_printf__ or the __printf__ attribute. It all boils down to compatibility across multiple versions of mingw headers. Older mingw only understands %I64d inside printf (__printf__ format); newer mingw optionally understands %lld instead (__gnu_printf__ format). But the newer mingw <inttypes.h> definition of PRIdMAX depends on whether you have explicitly requested modern printf. Our 'extensions' module unconditionally defines the __USE_MINGW_ANSI_STDIO switch to take advantage of newer mingw; but that macro does nothing on older mingw. If we then turn on __gnu_printf__ unconditionally, we get gcc warnings about unknown %lld on older mingw; conversely, if we don't turn on __gnu_printf when required, we get gcc warnings about unknown %I64d on newer mingw. > > By "test directly" I mean compile a little test program with printf and > see whether GCC warns about misuse. By seeing what GCC warns about and > what it doesn't we should be able to figure out which attribute is > appropriate. Testing whether a compiler warns or does not warn is also a rather difficult test; unless you temporarily add -Werror, it doesn't change exit status; and results in requiring multiple compilations to determine if you are even triggering a compiler warning due to unknown options vs. the actual warning from gcc. I'm still open to any cleaner test, easy enough to maintain. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature