Skip to content

MSVC 14.1 warning: unreferenced parameter in stdtuple.hpp #167

@anarthal

Description

@anarthal

Compiler: MSVC 14.1 (Visual Studio 2017)
The full build log is here: https://drone.cpp.al/boostorg/mysql/621/31/2

The following warning is emitted:

.\boost/pfr/detail/stdtuple.hpp(20): error C2220: warning treated as error - no 'object' file generated
.\boost/pfr/detail/stdtuple.hpp(20): warning C4100: 't': unreferenced formal parameter
.\boost/pfr/core.hpp(147): note: see reference to function template instantiation 'std::tuple<> boost::pfr::detail::make_stdtuple_from_tietuple<boost::pfr::detail::sequence_tuple::tuple<>,>(const T &,std::integer_sequence<unsigned int>)' being compiled
        with
        [
            T=boost::pfr::detail::sequence_tuple::tuple<>
        ]

When using pfr::structure_to_tuple with an empty struct. This is caused by the following code in detail/stdtuple.hpp:

template <class T, std::size_t... I>
constexpr auto make_stdtuple_from_tietuple(const T& t, std::index_sequence<I...>) {
    return std::make_tuple(
        boost::pfr::detail::sequence_tuple::get<I>(t)...
    );
}

This is actually a bug in MSVC 14.1. It will emit the warning if t is an empty tuple. It can be silenced by sticking a boost::ignore_unused(t).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions