From 1315133b50fd836f5b8bafc8bf63c85aef475a04 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 13 Dec 2022 12:38:33 +0100 Subject: [PATCH] Improve cast safety MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> --- src/libcmd/repl.cc | 2 +- src/libexpr/eval.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 254c14d28..5400fcd69 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -217,7 +217,7 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi // prefer direct pos, but if noPos then try the expr. auto pos = dt.pos ? dt.pos - : (std::shared_ptr) positions[dt.expr.getPos() ? dt.expr.getPos() : noPos]; + : static_cast>(positions[dt.expr.getPos() ? dt.expr.getPos() : noPos]); if (pos) { out << pos; diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index b5e0051ac..adf928949 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -823,7 +823,7 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & ? std::make_unique( *this, DebugTrace { - .pos = error->info().errPos ? error->info().errPos : (std::shared_ptr) positions[expr.getPos()], + .pos = error->info().errPos ? error->info().errPos : static_cast>(positions[expr.getPos()]), .expr = expr, .env = env, .hint = error->info().msg, @@ -1246,7 +1246,7 @@ void EvalState::cacheFile( *this, *e, this->baseEnv, - e->getPos() ? (std::shared_ptr) positions[e->getPos()] : nullptr, + e->getPos() ? static_cast>(positions[e->getPos()] : nullptr), "while evaluating the file '%1%':", resolvedPath) : nullptr;