From 53af5b2dd2069680be4ce76626c857e9b2959f77 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 12 Sep 2024 16:21:31 +0200 Subject: [PATCH] [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 --- .../Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst | 2 ++ configure | 6 ++++-- configure.ac | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst diff --git a/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst b/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst new file mode 100644 index 000000000000..4cf4a177f151 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst @@ -0,0 +1,2 @@ +Fix the check for the ``crypt()`` function in the configure script. Patch by +Paul Smith and Victor Stinner. diff --git a/configure b/configure index 173674073ca5..1c75810d9e8c 100755 --- a/configure +++ b/configure @@ -22041,16 +22041,18 @@ else $as_nop #include #endif #include + 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; diff --git a/configure.ac b/configure.ac index f22e71f46fea..d0d54050286c 100644 --- a/configure.ac +++ b/configure.ac @@ -5237,12 +5237,14 @@ WITH_SAVE_ENV([ #include #endif #include + 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]) ]) -- 2.47.3