From 0f4ef5f466ec49ef76b8882e2e66b4a13449999b Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Thu, 3 Jun 2021 15:51:01 +1000 Subject: [PATCH] prevent undefined behaviour at a language level while probing getenv This test in Configure tries to probe for undefined behaviour in getenv(), but provokes undefined behaviour in C/C++ by falling off the end of a function with a non-void return type. Without optimization clang++ generated a ud2 instruction here on amd64 producing an illegal instruction exception. With optimization the test case fell off the end and started re-executing main(), eventually producing a SIGBUS. Simply dropping the value of getenv() here and returning NULL wasn't useful, under -O2 the compiler optimized away the getenv() call, voiding the whole point of the test. --- Configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configure b/Configure index 6f8ae66f61f8..46f68258a74e 100755 --- a/Configure +++ b/Configure @@ -14249,7 +14249,7 @@ $cat >try.c <