Skip to content

Incorrectly assuming operator-> exists#333

Merged
sgerbino merged 1 commit into
cppalliance:develop-2from
term-est:buffer-fix
Jun 23, 2026
Merged

Incorrectly assuming operator-> exists#333
sgerbino merged 1 commit into
cppalliance:develop-2from
term-est:buffer-fix

Conversation

@term-est

Copy link
Copy Markdown

Not necessarily.

Consider

		char a[] = "ab";
		char b[] = "cd";

		std::array bufs
		{
			const_buffer(a, 2),
			const_buffer(b, 2)
		};

		auto seq = bufs | std::views::transform([](const_buffer x) { return x; }); // sponsored by SG9

		static_assert(ConstBufferSequence<decltype(seq)>);

		// Fails in detail::linearize_buffers because transform_view's iterator
		// does not provide operator->
		std::ignore = detail::search_buffer_for_match(seq, match_delim{"bc"});

Example uses detail::API directly to reproduce the issue, but it can also be triggered through the public exposing API as well by passing a crafted weird_dyn_buffer of sorts:

	struct weird_dynamic_buffer
	{
		char a[2] = {'a', 'b'};
		char b[2] = {'c', 'd'};

		std::array<const_buffer, 2> readable
		{
			const_buffer(a, 2),
			const_buffer(b, 2)
		};

		char scratch[16]{};

		static constexpr auto id = [](const_buffer x) { return x; };

		using const_buffers_type = decltype(std::declval<std::array<const_buffer, 2> const&>() | std::views::transform(id)); // sponsored by SG9

		using mutable_buffers_type = mutable_buffer;

		std::size_t size() const noexcept { return 4; }

		std::size_t max_size() const noexcept { return 16; }

		std::size_t capacity() const noexcept { return 12; }

		const_buffers_type data() const { return readable | std::views::transform(id); }

		mutable_buffers_type prepare(std::size_t n) { return mutable_buffer(scratch, n); }

		void commit(std::size_t) {}

		void consume(std::size_t) {}
	};

	static_assert(DynamicBuffer<weird_dynamic_buffer>);

	task<void> fumo_fumo()
	{
		test::read_stream rs;

		weird_dynamic_buffer db;

		std::ignore = co_await read_until(rs, db, "bc");
	}

@cppalliance-bot

cppalliance-bot commented Jun 23, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://333.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-06-23 18:13:04 UTC

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.07%. Comparing base (9144290) to head (f1e5f90).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop-2     #333   +/-   ##
==========================================
  Coverage      98.07%   98.07%           
==========================================
  Files            164      164           
  Lines           8774     8776    +2     
==========================================
+ Hits            8605     8607    +2     
  Misses           169      169           
Flag Coverage Δ
linux 98.17% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/boost/capy/read_until.hpp 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9144290...f1e5f90. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot

cppalliance-bot commented Jun 23, 2026

Copy link
Copy Markdown

GCOVR code coverage report https://333.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://333.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://333.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-06-23 18:32:00 UTC

@sgerbino sgerbino changed the base branch from develop to develop-2 June 23, 2026 18:07
@sgerbino sgerbino merged commit 48d15ef into cppalliance:develop-2 Jun 23, 2026
38 checks passed
@term-est term-est deleted the buffer-fix branch June 23, 2026 20:31
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.

3 participants