[Hana] "basic_tuple.hpp" bug when building with VS2017

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Hana] "basic_tuple.hpp" bug when building with VS2017

Boost - Dev mailing list
Hello,

Just installed Boost  and Visual Studio 2017 a few days ago.

Here is a bug when building with Hana's "basic_tuple.hpp" header with Visual Studio 2017: In basic_tuple.hpp:

    template <>
    struct drop_front_impl<basic_tuple_tag> {
        template <std::size_t N, typename Xs, std::size_t ...i>
        static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
            return hana::make_basic_tuple(
                detail::ebo_get<detail::bti<i+N>>(static_cast<Xs&&>(xs))...
            );
        }

        template <typename Xs, typename N>
        static constexpr auto apply(Xs&& xs, N const&) {
            constexpr std::size_t len = detail::decay<Xs>::type::size_;
            return drop_front_helper<N::value>(static_cast<Xs&&>(xs), std::make_index_sequence<
                N::value < len ? len - N::value : 0
            >{}); //<Bug here - line 197 of basic_tuple.hpp
        }
    };

Upon building with "basic_tuple.hpp", the line highlighted in green reports an error:

       "syntax error: unexpected token ')', expected 'id-expression'".

Focus on the line above that one:

       N::value < len ? len - N::value : 0

If you add parentheses, the error goes away:

              (N::value < len) ? len - N::value : 0

A similar bug occurs - and is fixed likewise - in the "string.hpp" header file at line 275, that is:
    template <>
    struct drop_front_impl<string_tag> {

        ...

        template <char ...xs, typename N>
        static constexpr auto apply(string<xs...> const& s, N const&) {
            return helper<N::value>(s, std::make_index_sequence<
                N::value < sizeof...(xs) ? sizeof...(xs) - N::value : 0
            >{}); //<bug here - line 275 of string.hpp
        }

I'm not sure if this is a Microsoft compiler issue (I will post to them as well), but I feel like someone should add those parentheses (and then some) to the line since it is safer - the "<" can be easily confused for a template bracket instead of a less-than sign by a parser.




Daniel Chen
Infinera







_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [Hana] "basic_tuple.hpp" bug when building with VS2017

Boost - Dev mailing list
AMDG

On 05/17/2018 11:59 AM, Daniel Chen via Boost wrote:

> <snip>
> Upon building with "basic_tuple.hpp", the line highlighted in green reports an error:
>
>        "syntax error: unexpected token ')', expected 'id-expression'".
>
> Focus on the line above that one:
>
>        N::value < len ? len - N::value : 0
>
> If you add parentheses, the error goes away:
>
>               (N::value < len) ? len - N::value : 0
>
> <snip>
>
> I'm not sure if this is a Microsoft compiler issue (I will post to them as well), but I feel like someone should add those parentheses (and then some) to the line since it is safer - the "<" can be easily confused for a template bracket instead of a less-than sign by a parser.
>

According to the standard, it is not parsed as a template
unless you say `N::template value`.  Are you using `/permissive-`?
That sometimes helps with these issues.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost