Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter name "data" in message_t constructor reuses the method name (warning when compiling user code) #641

Open
ethouris opened this issue May 23, 2024 · 0 comments

Comments

@ethouris
Copy link

ethouris commented May 23, 2024

gcc issues a warning:

warning: declaration of 'data' shadows a member of 'zmq::message_t' [-Wshadow]

It's issued by this constructor declaration:

    template<
      class Char,
      size_t N,
      typename = typename std::enable_if<detail::is_char_type<Char>::value>::type>
    ZMQ_DEPRECATED("from 4.7.0, use constructors taking iterators, (pointer, size) "
                   "or strings instead")
    explicit message_t(const Char (&data)[N]) :
        message_t(detail::ranges::begin(data), detail::ranges::end(data))
    {
    }

    template<class Range,
             typename = typename std::enable_if<
               detail::is_range<Range>::value
               && ZMQ_IS_TRIVIALLY_COPYABLE(detail::range_value_t<Range>)
               && !detail::is_char_type<detail::range_value_t<Range>>::value
               && !std::is_same<Range, message_t>::value>::type>
    explicit message_t(const Range &rng) :
        message_t(detail::ranges::begin(rng), detail::ranges::end(rng))
    {
    }

It actually doesn't matter if this is deprecated - this problem is reported regardless whether this constructor is in use or not.

It's easy to fix - just use a different name than data - which is simultaneously a name of the method in message_t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant