Repository navigation
Assert when using std::views::filter and GCC 10 #4440
Description
Activity
In #4498 I added the code above as test case. I get the same assertion error in the job for GCC 10.5. Furthermore, the test does not compiler with Clang 11. The test succeed with GCC 13.0 and Clang 19. Interestingly, there are no errors on Windows and macOS.
To summarize (see https://github.com/nlohmann/json/actions/runs/11878152025):
Does not work:
- GCC 10.5.0 (assertion)
- Clang 11.1.0 (compilation error)
- Clang 12.0.1 (compilation error)
- Clang 13.0.1 (compilation error)
- Clang 14.0.6 (compilation error)
- Clang 15.0.7 (compilation error)
Works:
- GCC 11.5.0
- GCC 12.4.0
- GCC 13.3.0
- GCC 14.2.0
- Clang 16.0.6
- Clang 17.0.6
- Clang 18.1.8
- Clang 19.1.4
Test skipped:
- GCC 9.5.0
So the feature works as expected with reasonably modern versions of GCC and Clang. The assertion in GCC 10.5.0 feels to me like a shortcoming of the implementation of
std::views::filter. Maybe there is some documentation about the implementation status of ranges in GCC that can confirm this.For Clang, we see the features works as expected starting with Clang 16. The previous versions in the CI fail to compile the code. However, these tests rely on libstdc++ instead of libc++. Once I have some time, I will try to use libc++ with these compilers to check the behavior.
If there is nothing in the library to fix this, then we can use Hedley to detect non-compliant compilers to exclude the test case and add a section to the documentation/README about ranges support.
Any thoughts on this?
- addedstate: please discussplease discuss the issue or vote for your favorite optionplease discuss the issue or vote for your favorite optionstate: help neededthe issue needs help to proceedthe issue needs help to proceed
on Nov 18, 2024 This issue has been marked as stale because it has been open for 90 days without activity. If this issue is still relevant, please add a comment or remove the "stale" label. Otherwise, it will be closed in 10 days. Thank you for helping us prioritize our work!
- addedstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
on Feb 17, 2025 This issue has been closed after being marked as stale for 10 days without any further activity. If this was done in error or the issue is still relevant, please feel free to reopen it or create a new issue. We appreciate your understanding and contributions.
4 remaining items
- added 2 commits that reference this issue
on May 25, 2025 - addedsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmationand removedstate: please discussplease discuss the issue or vote for your favorite optionplease discuss the issue or vote for your favorite optionstate: help neededthe issue needs help to proceedthe issue needs help to proceedstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
on Jun 30, 2026 - added a commit that references this issue
on Jun 30, 2026 - added a commit that references this issue
on Aug 20, 2026 - added 2 commits that reference this issue
on Aug 31, 2026 - added a commit that references this issue
on Sep 10, 2026 - added a commit that references this issue
on Sep 21, 2026
Description
After upgrading from
3.9.1to3.11.3the code asserts when iterating over a json array that's been filtered usingstd::views::filterdue to an uninitialized iterator.In addition to my failure with 3.11.3 and GCC 10.2, I checked other combinations on Godbolt and observed the following (❌ represents the assert is seen)
Reproduction steps
https://godbolt.org/z/WbexYTqnf
Expected vs. actual results
std::views::filtershould allow you to filter a json array.Minimal code example
Error messages
Compiler and operating system
GCC 10.2
Library version
3.11.3
Validation
developbranch is used.