0

I have the following very simple program that seems to fail on the Intel compiler but not gcc when using boost::lexical_cast (boost version 1.67.0):

#include <boost/lexical_cast.hpp>
#include <string>
#include <iostream>

float getSomeNumber()
{
  return 10.0;
}

int main(int argc, char** argv)
{
   std::string mystring("Hello: " + boost::lexical_cast<std::string>(getSomeNumber());
   std::cout << mystring << std::endl;
   return 0;
}

When compiling, Intel returns the following error:

 /boost/1.67.0/include/boost/type_traits/is_complete.hpp(45): warning #70: incomplete type is not allowed

       ok_tag<sizeof(T)> check_is_complete(int);
       detected during ....
       ...

/boost/1.67.0/include/boost/type_traits/is_complete.hpp(51): error: template instantiation resulted in unexpected function type of "boost::detail::ok_tag<1U> (int)" (the meaning of a name may have changed since the template declaration -- the type of the template is "boost::detail::ok_tag<sizeof(T)> (int)")
       ...

     detected during: 
        instantiation of "boost::detail::check_is_complete" based on template argument <void> at line 51
        instantiation of class "boost::is_complete<T> [with T=void]" at line 484 of "/Path/to/boost/include/boost/type_traits/is_convertible.hpp"
        ...
        instantiation of "Target boost::lexical_cast<Target, Source>(const Source &) [with Target=std::string, Source=float]" at line 11 of "boostTest.cc"

The best I can tell from this error is it seems like the compiler can't complete the template resolution, but then the very end it seems like it does? I tried compiling the same thing under gcc (version 4.8.5) and it worked fine. This code also previously worked fine under boost 1.64.0 with both gcc and Intel.

Is this a bug in the Intel Compiler, or perhaps a bug in boost? Is there a way to modify my program as a workaround?

Software versions

gcc: 4.8.5

Intel Compiler: 2015.3.187

Boost: 1.67.0

OS: RHEL 7.5 (Maipo)

Compile line:

icpc/gcc --std=c++11 boostTest.cc -o boostTest -Ipath/to/boost/include -lstdc++

stix
  • 1,098
  • 11
  • 34
  • boost libs usually give a list of compilers they work on . If the intel compiler/version is listed, then it's a bug and submit it to boost. If not, submit it to intel. Workarounds can be hard to find. For MS often if you search their bug database for the error message you'll find a workaround, but they're often not really sensical, since they revolve around a compiler bug... for isntance I had to change is_const_v to is_const::value for a MSVC bug recently. But there's no "logic" to be had about why that's the case without understanding the actual implementation bug involved. – xaxxon Aug 14 '19 at 21:56
  • Easy workaround in this case is to use `std::to_string` – M.M Aug 14 '19 at 23:06
  • @M.M That's only a workaround if you have access to a c++17 compiler ;P – stix Aug 16 '19 at 21:26
  • @stix It was added in C++11 – M.M Aug 16 '19 at 22:36
  • @M.M Not according to gcc 4.8.5 – stix Aug 16 '19 at 22:43
  • @stix it's part of the standard library, not the compiler per se. You might have a buggy implementation, [see here](https://stackoverflow.com/questions/12975341/to-string-is-not-a-member-of-std-says-g-mingw) – M.M Aug 16 '19 at 23:09
  • @M.M That's.... weird... Using Intel std::to_string is present, but using gcc 4.8.5, it isn't. Both are using --std=c++11... – stix Aug 19 '19 at 15:49
  • @stix as I said, you're using a buggy port of gcc – M.M Aug 19 '19 at 22:49
  • I raised this issue upstream at https://github.com/boostorg/type_traits/issues/138 – Nehal J Wani Feb 15 '20 at 19:13

0 Answers0