mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-03 07:31:41 +01:00
Disable unsafe implicit conversion to std::string (#729)
This commit is contained in:
@@ -9,8 +9,7 @@ set(CMAKE_REQUIRED_FLAGS ${CPP14_FLAG})
|
||||
function (generate_source result fragment)
|
||||
set(${result} "
|
||||
#define FMT_HEADER_ONLY 1
|
||||
#include \"fmt/posix.h\"
|
||||
#include \"fmt/ostream.h\"
|
||||
#include \"fmt/format.h\"
|
||||
int main() {
|
||||
${fragment}
|
||||
}
|
||||
@@ -58,6 +57,14 @@ expect_compile_error("fmt::format(\"{}\", L\"foo\");")
|
||||
# mixing UTF-8 with UTF-16/32 can result in an invalid output.
|
||||
expect_compile_error("fmt::format(L\"{}\", \"foo\");")
|
||||
|
||||
# Formatting a wide string with a narrow format string is forbidden.
|
||||
expect_compile_error("
|
||||
struct S {
|
||||
operator std::string() const { return std::string(); }
|
||||
};
|
||||
fmt::format(\"{}\", S());
|
||||
")
|
||||
|
||||
# Make sure that compiler features detected in the header
|
||||
# match the features detected in CMake.
|
||||
if (SUPPORTS_USER_DEFINED_LITERALS)
|
||||
|
||||
Reference in New Issue
Block a user