Skip to content

Commit 4f4a3a8

Browse files
committed
Protection
r-lib/cpp11#422 This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.
1 parent aa3225d commit 4f4a3a8

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

inst/include/cpp11/protect.hpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,10 @@ void stop [[noreturn]] (const std::string& fmt_arg, Args&&... args) {
203203
safe.noreturn(Rf_errorcall)(R_NilValue, "%s", msg.c_str());
204204
}
205205

206-
template <typename... Args>
207-
void warning(const char* fmt_arg, Args&&... args) {
208-
std::string msg = fmt::format(fmt_arg, std::forward<Args>(args)...);
209-
safe[Rf_warningcall](R_NilValue, "%s", msg.c_str());
210-
}
206+
// Always making copy of string to avoid weird unwind behavior.
211207

212208
template <typename... Args>
213-
void warning(const std::string& fmt_arg, Args&&... args) {
209+
void warning(const std::string fmt_arg, Args&&... args) {
214210
std::string msg = fmt::format(fmt_arg, std::forward<Args>(args)...);
215211
safe[Rf_warningcall](R_NilValue, "%s", msg.c_str());
216212
}
@@ -225,13 +221,10 @@ void stop [[noreturn]] (const std::string& fmt, Args... args) {
225221
safe.noreturn(Rf_errorcall)(R_NilValue, fmt.c_str(), args...);
226222
}
227223

228-
template <typename... Args>
229-
void warning(const char* fmt, Args... args) {
230-
safe[Rf_warningcall](R_NilValue, fmt, args...);
231-
}
224+
// Always making copy of string to avoid weird unwind behavior.
232225

233226
template <typename... Args>
234-
void warning(const std::string& fmt, Args... args) {
227+
void warning(const std::string fmt, Args... args) {
235228
safe[Rf_warningcall](R_NilValue, fmt.c_str(), args...);
236229
}
237230
#endif

0 commit comments

Comments
 (0)