Skip to content

Regression: Invalid assertion in string assign (and probably other functions) #346

Description

@liss-h

boost::container::string::assign checks BOOST_ASSERT(s != 0)

basic_string& assign(const CharT* s, size_type n)
{
BOOST_ASSERT(s != 0);
return this->assign(s, s + difference_type(n));
}

This is invalid for default constructed std::string_view.

"1) Default constructor. Constructs an empty std::basic_string_view. After construction, data() is equal to nullptr, and size() is equal to 0." - https://en.cppreference.com/cpp/string/basic_string_view/basic_string_view

The check should have been BOOST_ASSERT(s != nullptr || n == 0);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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