Originally reported to fmt repo here...
https://github.com/fmtlib/fmt/issues/1339
It appears the test_package.cpp is incorrectly using the buffer.data() in it's print statement on line 45...
fmt::print("Euler number: {}\n", buf.data());
This is causing a non-null-terminated output such as...
Euler number: 2.71828╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠☺⌂Bç
┐♣@P∙O_∩
@keysight-daryl !
It's working normal for me. It can be related to your terminal. Which terminal do you use? Also, are you really running Conan 1.14.4?
I guess issue is that fmt::memory_buffer::data is not guaranteed to be null-terminated, so it's UB to output it as a string. we have to compose std::string from fmt::memory_buffer::data and fmt::memory_buffer::size in order to have null-terminated string.
The output can be converted to an std::string with to_string(out).
yes, conan 1.14.4 is the version we are locked at here at Keysight. I think the fmt dev indicated that the data() function is not intended to return a properly terminated string is the issue. It only caused a problem for debug builds in VS2017 but I supposed that it doesn't cause a problem otherwise is just a case of luck. I believe it should be changed to call to_string() instead.
It might be related to the fact that just recently fmt is supporting non string data in it's buffers.
Reviewing the proposed fix I believe it still has a bug. According to the docs to convert to a string is to call to_string(buf) not to_string(buf.data())
I would also like to recommend updating of the conanfile to properly package/import the associated *.pdb files for debug builds so that consumers avoid the 'missing PDB' compiler warnings. For example...
`
def imports(self):
self.copy('*.pdb', dst='bin', src='bin')
def package(self):
self.copy("LICENSE.rst", dst="licenses", src=self._source_subfolder)
if self.options.header_only:
src_dir = os.path.join(self._source_subfolder, "src")
header_dir = os.path.join(self._source_subfolder, "include")
dst_dir = os.path.join("include", "fmt")
self.copy("*.h", dst="include", src=header_dir)
self.copy("*.cc", dst=dst_dir, src=src_dir)
else:
cmake = self._configure_cmake()
cmake.install()
self.copy('*.pdb', dst='bin', keep_path=False)
`
PDB files aren't allowed for CCI recipes https://github.com/conan-io/conan-center-index/wiki/Error-Knowledge-Base#kb-h017-pdb-files-not-allowed
kind of makes it hard for consumers to debug through, important in discovering bugs caused by package upgrades
Most helpful comment
I guess issue is that
fmt::memory_buffer::datais not guaranteed to be null-terminated, so it's UB to output it as a string. we have to composestd::stringfromfmt::memory_buffer::dataandfmt::memory_buffer::sizein order to have null-terminated string.doc