[3.12] gh-123917: Fix crypt check in configure (#123952)

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>
This commit is contained in:
Victor Stinner 2024-09-12 16:21:31 +02:00 committed by GitHub
parent 5c15b1a05a
commit 53af5b2dd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View file

@ -0,0 +1,2 @@
Fix the check for the ``crypt()`` function in the configure script. Patch by
Paul Smith and Victor Stinner.

6
configure generated vendored
View file

@ -22041,16 +22041,18 @@ else $as_nop
#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;

View file

@ -5237,12 +5237,14 @@ WITH_SAVE_ENV([
#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])
])