[output,logging] Compilation may fail due to logging stream argument
Description:
The compile step can fail depending on the environment due to the passing of an outstream instance to the logger descriptor instead of the string itself.
Environment:
[glazzari@pcgpu-c2f07-18-01 src]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-20) (GCC)
Console output:
In file included from /usr/include/c++/8/istream:39,
from /usr/include/c++/8/fstream:38,
from OutputFile.h:7,
from OutputFileHandler.h:12,
from OutputFileHandler.cc:1:
/usr/include/c++/8/ostream:685:5: note: candidate: 'template<class _Ostream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_ostream<_Ostream>, std::__is_insertable<typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type, const _Tp&, void> >::value, typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type>::type std::operator<<(_Ostream&&, const _Tp&)'
operator<<(_Ostream&& __os, const _Tp& __x)
^~~~~~~~
/usr/include/c++/8/ostream:685:5: note: template argument deduction/substitution failed:
/usr/include/c++/8/ostream: In substitution of 'template<class _Ostream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_ostream<_Ostream>, std::__is_insertable<typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type, const _Tp&, void> >::value, typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type>::type std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::__cxx11::basic_ostringstream<char>&; _Tp = std::__cxx11::basic_stringstream<char>]':
log.h:119:8: required from 'tools::log::log& tools::log::log::operator<<(const T&) [with T = std::__cxx11::basic_stringstream<char>]'
OutputFileHandler.cc:196:40: required from here
/usr/include/c++/8/ostream:685:5: error: no type named 'type' in 'struct std::enable_if<false, std::basic_ostream<char>&>'
Potential fix:
A quick fix is to use the ostream::str()
member function to get a string instance and pass that to the file descriptor. This makes a redundant copy of the stream's underlying buffer, however.
In OutputFileHandler.cc:196
:
LOG(TRACE) << "writing EoR file " << EoR_filename.str();