Skip to content

Default initialized iterators are not comparable #4493

@piyooshm

Description

@piyooshm

Description

I have a use-case where I iterate over collections in a generic manner (using templates). However, iteration over basic_json fails due to the statement:

        JSON_ASSERT(m_object != nullptr);

Before asserting for non-null object, shouldn't we first check of other.m_object is null too? If both are null, the operator should return true before the assertion.

Reproduction steps

nlohmann::json::iterator{} == nlohmann::json::iterator{}

Expected vs. actual results

Expected: Should return true of m_object is nullptr for both objects

Actual: Assertion fails

Minimal code example

No response

Error messages

No response

Compiler and operating system

gcc 9.3

Library version

3.11.3

Validation

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions