From b866601b6398f90967c8ab120f9b9806869f94c4 Mon Sep 17 00:00:00 2001 From: "D. Shah" Date: Wed, 3 Feb 2021 19:43:33 +0000 Subject: Fix now-illegal use of reinterpret_cast Signed-off-by: D. Shah --- common/nextpnr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/nextpnr.h b/common/nextpnr.h index ad89046c..263c8e13 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -841,6 +841,8 @@ struct BaseCtx // Context meta data std::unordered_map attrs; + Context *as_ctx = nullptr; + BaseCtx() { idstring_str_to_idx = new std::unordered_map; @@ -914,9 +916,9 @@ struct BaseCtx IdString id(const char *s) const { return IdString(this, s); } - Context *getCtx() { return reinterpret_cast(this); } + Context *getCtx() { return as_ctx; } - const Context *getCtx() const { return reinterpret_cast(this); } + const Context *getCtx() const { return as_ctx; } const char *nameOf(IdString name) const { return name.c_str(this); } @@ -1245,7 +1247,7 @@ struct Context : Arch, DeterministicRNG // Should we disable printing of the location of nets in the critical path? bool disable_critical_path_source_print = false; - Context(ArchArgs args) : Arch(args) {} + Context(ArchArgs args) : Arch(args) { BaseCtx::as_ctx = this; } // -------------------------------------------------------------- -- cgit v1.2.3