From 52b4821a6eab9fc496de2e132ef0744c1e573ca4 Mon Sep 17 00:00:00 2001 From: minqiyang Date: Mon, 24 Dec 2018 19:24:02 +0800 Subject: [PATCH] Fix Sprintf problem test=develop --- paddle/fluid/platform/enforce.h | 2 +- paddle/fluid/string/printf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index e9b98aee1f..0668053950 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -261,7 +261,7 @@ inline void throw_on_error(T e) { #define __PADDLE_THROW_ERROR_I(_, _9, _8, _7, _6, _5, _4, _3, _2, X_, ...) X_; #define __THROW_ON_ERROR_ONE_ARG(COND, ARG) \ - ::paddle::platform::throw_on_error(COND, "%s", std::string(ARG)); + ::paddle::platform::throw_on_error(COND, ::paddle::string::Sprintf(ARG)); #define __PADDLE_THROW_ON_ERROR(COND, ...) \ __PADDLE_THROW_ERROR_I( \ diff --git a/paddle/fluid/string/printf.h b/paddle/fluid/string/printf.h index a2eec6e3c4..0b94b60018 100644 --- a/paddle/fluid/string/printf.h +++ b/paddle/fluid/string/printf.h @@ -87,7 +87,7 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) { template std::string Sprintf(const Args&... args) { std::ostringstream oss; - Fprintf(oss, ""); + Fprintf(oss, "%s", args...); return oss.str(); } -- GitLab