Issue 25397: improve ac_cv_have_long_long_format GCC fallback (original) (raw)
the ac_cv_have_long_long_format test has a nice compile-time fallback for gcc based compilers: CFLAGS="$CFLAGS -Werror -Wformat" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> #include <stddef.h> ]], [[ char *buffer; sprintf(buffer, "%lld", (long long)123); sprintf(buffer, "%lld", (long long)-123); sprintf(buffer, "%llu", (unsigned long long)123); ]])], ac_cv_have_long_long_format=yes )
unfortunately, this turns on the global -Werror flag in order to check things. that means if the code triggers unrelated warnings, the test still fails ;(. this comes up w/bionic which complains about unsafe use of the sprintf function, and can come up in general in this code because buffer is not initialized :).
the good news is that gcc-4.2 has supported a directed -Werror=format option. https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Warning-Options.html
so instead of using -Werror -Wformat, you could use -Werror=format. the downside is that the fallback no longer works with <=gcc-4.1, but maybe that's ok considering gcc-4.2 was released May 2007 (almost 9 years ago) ?
note: this also applies to various other tests in the configure file.
NB: landing a fix in py3.5+ (and ignoring 3.[0-4]) is fine, but please also to fix py2.7 :)