Skip to content

length_func<CharT>::operator() fails CppCoreCheck #451

Closed

Description

Running CppCoreCheck with VS2017 RC fails with:

warning C26461: The pointer argument 'ptr' for function gsl::details::length_func<char>::operator() can be marked as a pointer to const. (con.3: https://go.microsoft.com/fwlink/p/?LinkID=786684)
warning C26461: The pointer argument 'ptr' for function gsl::details::length_func<wchar_t>::operator() can be marked as a pointer to const. (con.3: https://go.microsoft.com/fwlink/p/?LinkID=786684)

Seems like the placement of const is incorrect:

template <>
struct length_func<char>
{
    std::ptrdiff_t operator()(char* const ptr, std::ptrdiff_t length) GSL_NOEXCEPT
    {
        return details::string_length(ptr, length);
    }
};

Should likely be declared as const char* ptr or perhaps const char* const ptr.

Activity

  1. neilmacintosh commented on Feb 28, 2017

    @neilmacintosh
    Contributor

    Nice catch Duncan Horn (@duncanhorn). Would you like to offer a PR?

  2. duncanhorn commented on Feb 28, 2017

    @duncanhorn
    ContributorAuthor

    Sure thing. #458

  3. neilmacintosh commented on Mar 24, 2017

    @neilmacintosh
    Contributor

    This was closed thanks to the #458 from Duncan Horn (@duncanhorn).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions