Subject: Re: [boost] [Proto] Errors due to narrowing conversions in matches.hpp
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-04-22 01:22:24


Eric Niebler wrote:
>> Some tests of Boost.Phoenix fail on clang trunk in a C++11 mode
>> due to narrowing conversions of non-type template arguments,
>> which are prohibited in C++11.
>
> Really?! Wow, that's a breaking change I hadn't heard of before.

Let me elaborate a bit.
On clang-cxx11-r155296 test runner,
( http://www.boost.org/development/tests/trunk/developer/phoenix.html )
there are many failures due to the following errors.

    boost/proto/matches.hpp:354:17:
    error: non-type template argument evaluates to 2,
    which cannot be narrowed to type 'bool' [-Wc++11-narrowing]

    boost/proto/matches.hpp:363:21:
    error: non-type template argument evaluates to 2,
    which cannot be narrowed to type 'bool' [-Wc++11-narrowing]

The problem is that
    remove_reference<
        typename when<_, If>::template impl<Expr, int, int>::result_type
>::type::value
evaluates to "2", which is not in the range of bool.
This causes the compiler errors.

> Ideally, this should be a valid MPL Integral Constant of type bool, like:
>
> template< class T >
> struct is_placeholder
>  : mpl::false_
> {};
>
> If that is not portable enough, it could be:
>
> template< class T > struct is_placeholder
> {
>    BOOST_STATIC_CONSTANT(bool, value = false);
> };

Neither of them solve the problem.
After applying the proposed change, we still have the same errors.

Regards,
Michel