Skip to content

Commit 88aa79b

Browse files
committed
WASM: Fix neg val assign to global_var_idx
1 parent c9f4631 commit 88aa79b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libasr/codegen/asr_to_wasm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <chrono>
44
#include <iomanip>
55
#include <fstream>
6+
#include <climits>
67

78
#include <libasr/asr.h>
89
#include <libasr/exception.h>
@@ -526,7 +527,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
526527

527528
using namespace wasm;
528529
int kind = ASRUtils::extract_kind_from_ttype_t(v->m_type);
529-
uint32_t global_var_idx = -1;
530+
uint32_t global_var_idx = UINT_MAX;
530531
switch (v->m_type->type){
531532
case ASR::ttypeType::Integer: {
532533
uint64_t init_val = 0;
@@ -583,7 +584,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
583584
global_var_idx = m_wa.declare_global_var(i32, 0);
584585
}
585586
}
586-
LCOMPILERS_ASSERT(global_var_idx >= 0);
587+
LCOMPILERS_ASSERT(global_var_idx < UINT_MAX);
587588
m_global_var_idx_map[get_hash((ASR::asr_t *)v)] = global_var_idx;
588589
}
589590

0 commit comments

Comments
 (0)