From 4f4a3a8478135a572ffd36fc89ae3d1cb9f2c280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 7 Dec 2024 20:32:55 +0100 Subject: [PATCH] Protection https://github.com/r-lib/cpp11/pull/422 This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b. --- inst/include/cpp11/protect.hpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/inst/include/cpp11/protect.hpp b/inst/include/cpp11/protect.hpp index df8f4ef19..b30d95c45 100644 --- a/inst/include/cpp11/protect.hpp +++ b/inst/include/cpp11/protect.hpp @@ -203,14 +203,10 @@ void stop [[noreturn]] (const std::string& fmt_arg, Args&&... args) { safe.noreturn(Rf_errorcall)(R_NilValue, "%s", msg.c_str()); } -template -void warning(const char* fmt_arg, Args&&... args) { - std::string msg = fmt::format(fmt_arg, std::forward(args)...); - safe[Rf_warningcall](R_NilValue, "%s", msg.c_str()); -} +// Always making copy of string to avoid weird unwind behavior. template -void warning(const std::string& fmt_arg, Args&&... args) { +void warning(const std::string fmt_arg, Args&&... args) { std::string msg = fmt::format(fmt_arg, std::forward(args)...); safe[Rf_warningcall](R_NilValue, "%s", msg.c_str()); } @@ -225,13 +221,10 @@ void stop [[noreturn]] (const std::string& fmt, Args... args) { safe.noreturn(Rf_errorcall)(R_NilValue, fmt.c_str(), args...); } -template -void warning(const char* fmt, Args... args) { - safe[Rf_warningcall](R_NilValue, fmt, args...); -} +// Always making copy of string to avoid weird unwind behavior. template -void warning(const std::string& fmt, Args... args) { +void warning(const std::string fmt, Args... args) { safe[Rf_warningcall](R_NilValue, fmt.c_str(), args...); } #endif