Use a global volatile variable and check if the function is not NULL
to use the variable. Otherwise, a compiler optimization can remove
the variable making the check useless.
Co-authored-by: Paul Smith <paul@mad-scientist.net>
--- /dev/null
+Fix the check for the ``crypt()`` function in the configure script. Patch by
+Paul Smith and Victor Stinner.
#include <crypt.h>
#endif
#include <unistd.h>
+ volatile void *func;
int
main (void)
{
#ifdef HAVE_CRYPT_R
- void *x = crypt_r;
+ func = crypt_r;
#else
- void *x = crypt;
+ func = crypt;
#endif
+ return (func != NULL);
;
return 0;
#include <crypt.h>
#endif
#include <unistd.h>
+ volatile void *func;
], [
#ifdef HAVE_CRYPT_R
- void *x = crypt_r;
+ func = crypt_r;
#else
- void *x = crypt;
+ func = crypt;
#endif
+ return (func != NULL);
])
], [ac_cv_crypt_crypt=yes], [ac_cv_crypt_crypt=no])
])