diff --git a/inst/include/cpp11/protect.hpp b/inst/include/cpp11/protect.hpp index 9cb4876a..401b394f 100644 --- a/inst/include/cpp11/protect.hpp +++ b/inst/include/cpp11/protect.hpp @@ -201,14 +201,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()); } @@ -223,13 +219,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