Skip to content

Add missing <algorithm>/<iterator> includes in Serialization.hpp and Results.hpp - #348

Open
jonathon-bell wants to merge 1 commit into
emil-e:masterfrom
wolery:fix-missing-includes-serialization-results
Open

jonathon-bell wants to merge 1 commit into
emil-e:masterfrom
wolery:fix-missing-includes-serialization-results

Conversation

@jonathon-bell

Copy link
Copy Markdown
Contributor

These two headers use standard library facilities without including the headers that declare them — they always relied on some other header pulling in <algorithm>/<iterator> transitively. That's incidental, not guaranteed by the standard, and recent libc++ releases (Clang 23) no longer do it, so the build now fails:

$ cmake -S . -B build && cmake --build build
...
include/rapidcheck/detail/Results.hpp:26:22: error: no member named 'back_inserter' in namespace 'std'
      iit, end, std::back_inserter(out.shrinkPath));
                     ^~~~~~~~~~~~~
include/rapidcheck/detail/Serialization.hpp:48:10: error: no member named 'copy' in namespace 'std'
  return std::copy(begin(value), end(value), oit);
         ^~~~~~~~~
  • Serialization.hpp uses std::copy and std::distance but includes neither <algorithm> nor <iterator>.
  • Results.hpp uses std::back_inserter but does not include <iterator>.

Fix: add the missing includes directly to the headers that use them (IWYU). Reproduces the same way under -std=gnu++11 (rapidcheck's own project default) as under later standards — this isn't a C++17/20/23 compatibility issue, just a newer standard library shuffling its internal include graph. Same category as #345 (missing <exception> in Gen.hpp).

This should hold regardless of whether it reproduces on any particular CI toolchain: the standard never specifies that <unordered_map>/<string>/etc. must provide <algorithm> or <iterator>, so code relying on that is fragile by construction even where it currently happens to build. The fix is a pure addition of includes — zero behavioral change, and it cannot break any configuration that builds today.

Environment used to reproduce and verify: macOS, Clang 23.1.0, libc++, CMake, default -std=gnu++11 (rapidcheck's own build default — verified via cmake --build, independent of any consuming project's language standard).

Verified cmake --build succeeds for the rapidcheck target after the fix.

…Results.hpp

Serialization.hpp uses std::copy and std::distance but includes
neither <algorithm> nor <iterator>. Results.hpp uses
std::back_inserter but does not include <iterator>. Both
previously built only because some other transitively-included
header happened to pull these in; that incidental path doesn't
hold on all standard library versions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant