This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: distro test rebuild using GCC 6


On 15 January 2016 at 17:52, James Greenhalgh wrote:
>   vbrfix_0.24-7
>
>     [ Source error, not sure how this ever worked! ]
>
>     In file included from vbrfix.h:22:0,
>                      from vbrfix.cpp:17:
>     wputil.h: In static member function 'static bool wfile::copyFile(const char*, const char*, bool)':
>     wputil.h:202:28: error: cannot convert 'std::basic_ostream<char>' to 'bool' in return
>          return out << in.rdbuf();

In C++03 iostreams have an implicit conversion to void*, which can
then be implicitly converted to bool.

In C++11 they have an explicit conversion to bool, so the code needs
to be changed to do the conversion explicitly:

         return bool(out << in.rdbuf());

or

         return static_cast<bool>(out << in.rdbuf());

         if (out << in.rdbuf())
           return true;
         return false;

or

         return (out << in.rdbuf()) ? true : false;

or some similar variation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]