Landing: a4ceb702480b

Project / Subsystem

gcc / libstdc++

Date

2026-06-26

Author

Yan Churkin

Commit

a4ceb702480b9f46dd9b862c81ad7505ca344286

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
libstdc++
patch_id
commit_hash
a4ceb702480b9f46dd9b862c81ad7505ca344286
source_type
github
headline
Libstdc++: Avoid past-the-end iterator dereference with overloaded operator&&.
tldr
Libstdc++ algorithms now prevent dereferencing past-the-end iterators when custom operator&& is used in loop conditions.
author
Yan Churkin
outcome
committed
performance_win
false
breaking_change
false
series_id
series_parts
[]
tags
  • libstdc++
  • algorithm
  • iterator
  • bugfix
discussion_id_link
bugzilla_pr
date
2026-06-26T00:00:00.000Z

This commit addresses an issue in libstdc++ algorithms like std::__find_if and std::__mismatch where custom overloaded operator&& could lead to dereferencing past-the-end iterators. Such custom operators, if not designed for short-circuiting, would evaluate their operands even when the loop condition indicated the end of the range. The fix forces the predicate result to bool, ensuring the use of the built-in, short-circuiting && operator and preventing the dereference of invalid iterators.