summaryrefslogtreecommitdiff
path: root/Configure
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-06-03 15:51:01 +1000
committerTony Cook <tony@develop-help.com>2021-06-09 10:43:55 +1000
commita5823872283be23731f1bcde7e19a926c44b31a4 (patch)
tree87d1a0e15bbb12896321153b891e6b659c998020 /Configure
parent818defb9eb745d8ae4b08e9f313bde316f68aced (diff)
downloadperl-a5823872283be23731f1bcde7e19a926c44b31a4.tar.gz
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.
Diffstat (limited to 'Configure')
-rwxr-xr-xConfigure4
1 files changed, 2 insertions, 2 deletions
diff --git a/Configure b/Configure
index 6f8ae66f61..46f68258a7 100755
--- a/Configure
+++ b/Configure
@@ -14249,7 +14249,7 @@ $cat >try.c <<EOCP
void *
thread_start(void * arg)
{
- (void *) getenv("HOME");
+ return (void *) getenv("HOME");
}
int main() {
@@ -14280,7 +14280,7 @@ int main() {
exit(2);
}
- exit(! strcmp(main_buffer, save_main_buffer) == 0);
+ exit(! (strcmp(main_buffer, save_main_buffer) == 0));
}
EOCP
val=