summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-30 09:54:01 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-30 09:54:01 -0700
commitf21b2ba8f3772eb7d1207c214a181516b9d1f4e4 (patch)
treefbd825ab863c64eeb4791155e61b3126e099565c
parent14f41b23192e827a01201ac4296861290e221c1f (diff)
downloadnasm-f21b2ba8f3772eb7d1207c214a181516b9d1f4e4.tar.gz
BR 3392687: clang miscompiles offsetin() for uninitialized pointer
The actual pointer value in offsetin() cancels out, but clang still miscompiles offsetin() for an uninitialized pointer, considering the value to be completely undefined. Initialize pointer being passed to offsetin() to make clang happy; both the gcc and clang optimizers discover later in the code that the initialization is unused and removes it from the code. Although technically undefined behavior, this is in my opinion a severe quality of implementation bug in clang, and I will file a bug report accordingly. Reported-by: Jasper Lievisse Adriaanse <r+nasm@jasper.la> Reported-by: David Bohman <debohman@gmail.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--nasmlib/strlist.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/nasmlib/strlist.c b/nasmlib/strlist.c
index db5a09ab..449304b7 100644
--- a/nasmlib/strlist.c
+++ b/nasmlib/strlist.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2018 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -102,7 +102,8 @@ strlist_add(struct strlist *list, const char *str)
const struct strlist_entry *
strlist_vprintf(struct strlist *list, const char *fmt, va_list ap)
{
- struct strlist_entry *e;
+ /* clang miscompiles offsetin() unless e is initialized here */
+ struct strlist_entry *e = NULL;
struct hash_insert hi;
if (!list)