From 564c7404a6021f30d5ac6009cde362655afa5f3e Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 1 Aug 2019 12:34:47 +0100 Subject: [PATCH] Fix initialisation of vvp symbol table values. In 64-bit Windows, an unsigned long is 32 bits, so initialising the num member of the union did not properly initialise the ptr member. The num member isn't actually needed, so eliminate it. (cherry picked from commit c383d2048c0bd15f5db083f14736400546fb6215) --- vvp/compile.cc | 2 +- vvp/symbols.cc | 4 ++-- vvp/symbols.h | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vvp/compile.cc b/vvp/compile.cc index ef1e49bf9..1f8bbf024 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -639,7 +639,7 @@ struct code_label_resolv_list_s: public resolv_list_s { bool code_label_resolv_list_s::resolve(bool mes) { symbol_value_t val = sym_get_value(sym_codespace, label()); - if (val.num) { + if (val.ptr) { if (code->opcode == of_FORK) code->cptr2 = reinterpret_cast(val.ptr); else diff --git a/vvp/symbols.cc b/vvp/symbols.cc index e39920c4e..4f5a30f19 100644 --- a/vvp/symbols.cc +++ b/vvp/symbols.cc @@ -338,7 +338,7 @@ symbol_value_t symbol_table_s::find_value_(struct tree_node_*cur, assert(0); { symbol_value_t tmp; - tmp.num = 0; + tmp.ptr = 0; return tmp; } } @@ -366,7 +366,7 @@ void symbol_table_s::sym_set_value(const char*key, symbol_value_t val) symbol_value_t symbol_table_s::sym_get_value(const char*key) { symbol_value_t def; - def.num = 0; + def.ptr = 0; if (root->count == 0) { /* Handle the special case that this is the very first diff --git a/vvp/symbols.h b/vvp/symbols.h index dd21f8fb7..922bb8f08 100644 --- a/vvp/symbols.h +++ b/vvp/symbols.h @@ -49,7 +49,6 @@ typedef struct symbol_value_s { union { vvp_net_t*net; void*ptr; - unsigned long num; }; } symbol_value_t;