Fedora Account System
Red Hat Associate
Red Hat Customer
Created attachment 1391688 [details] Reproducer Description of problem: Attached is a stripped down reproducer from the uhd package which fails to compile with gcc-8.0.1-0.9, but compiles with the gcc-7.2.1-2. Version-Release number of selected component (if applicable): gcc-8.0.1-0.9.fc28.x86_64 boost-1.66.0-0.1.fc26.x86_64 How reproducible: Always Steps to Reproduce: 1. Compile attached reproducer 2. 3. Actual results: test2.c: In instantiation of ‘double max287x<max287x_regs_t>::set_frequency(double, bool) [with max287x_regs_t = max2871_regs_t]’: test2.c:28:41: required from here test2.c:19:56: error: cannot bind non-const lvalue reference of type ‘const char*&’ to an rvalue of type ‘const char*’ std::cout << boost::format("MAX287x: tune: type=%s") % ((is_int_n) ? "Integer-N" : "Fractional") << std::endl; In file included from /usr/include/boost/format.hpp:41, from test2.c:2: /usr/include/boost/format/format_class.hpp:67:44: note: initializing argument 1 of ‘boost::basic_format<Ch, Tr, Alloc>& boost::basic_format<Ch, Tr, Alloc>::operator%(T&) [with T = const char*; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>]’ template<class T> basic_format& operator%(T& x) ^~~~~~~~ Expected results: No error Additional info: I cannot see what's wrong with the code, it seems OK to me. The following workaround seems to make it compile again: - std::cout << boost::format("MAX287x: tune: type=%s") % ((is_int_n) ? "Integer-N" : "Fractional") << std::endl; + std::cout << boost::format("MAX287x: tune: type=%s") % ((is_int_n) ? std::string("Integer-N") : std::string("Fractional")) << std::endl;
This doesn't seem like a Boost (In reply to Jaroslav Škarvada from comment #0) > Description of problem: > Attached is a stripped down reproducer from the uhd package which fails to > compile with gcc-8.0.1-0.9, but compiles with the gcc-7.2.1-2. This is a GCC bug not a Boost bug, you get the same error for gcc-8 on f26 with boost-1.64.0 struct format { template<typename T> format& operator%(const T&) { return *this; } template<typename T> format& operator%(T&) { return *this; } }; format f; template <typename> void function_template(bool b) { // Compiles OK with array lvalue: f % (b ? "x" : "x"); // Fails with pointer rvalue: f % (b ? "" : "x"); } void normal_function(bool b) { // Both cases compile OK in non-template function: f % (b ? "x" : "x"); f % (b ? "" : "x"); function_template<void>(b); }
Reported upstream.
(In reply to Jaroslav Škarvada from comment #0) > The following workaround seems to make it compile again: > - std::cout << boost::format("MAX287x: tune: type=%s") % ((is_int_n) ? > "Integer-N" : "Fractional") << std::endl; > + std::cout << boost::format("MAX287x: tune: type=%s") % ((is_int_n) ? > std::string("Integer-N") : std::string("Fractional")) << std::endl; A better workaround is: std::cout << boost::format("MAX287x: tune: type=%s") % (const char*)((is_int_n) ? "Integer-N" : "Fractional") << std::endl; i.e. cast the conditional expression to const char* (which is the type it has anyway, but this avoids the GCC bug).
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle. Changing version to '28'.
Should be already fixed.