Canonical: https://botbento.com/usecases/flag-dangling-string-view-returns-in-c/
Format: Markdown representation of the public HTML page.

# Flag dangling string_view returns in C++ patches

[Coding](https://botbento.com/usecases/coding/) · Intermediate

Review diffs for views that outlive the temporaries they point at

A bot that reads incoming C++ diffs and traces the lifetime of string_view and similar view types. It checks whether a view is returned or stored beyond the scope of the buffer it refers to, calls out risky temporaries, and suggests passing views as parameters or returning owning strings instead.

## Quick answers

**What does it do?** Review diffs for views that outlive the temporaries they point at. Result: Post review notes on risky views.

**What does it need?** Tools: GitHub, Terminal, Docs. Intermediate: some setup. The prompt includes an approval step.

**How do I run it?** When something happens: C++ diff opened. Copy the prompt below into a bot in BotBento.

## How it works

1. When something happens: C++ diff opened
2. Then: Trace view lifetimes across the patch
3. Result: Post review notes on risky views

## Prompt to start with

```text
You watch C++ pull requests. For each changed function, trace where view types such as string_view come from and whether they point at temporaries, locals, or parameters. Flag any returned or stored view whose backing buffer may be destroyed before use. Recommend taking views as parameters or returning owning strings. Keep notes concise and cite the line. Draft review comments and wait for my approval before posting anything to the pull request.
```

## Tools it uses

GitHub, Terminal, Docs

## Works with

BotBento

## Tags

cpp, code-review, memory-safety, static-analysis, string-view

## Source

[Spooky C++](https://news.ycombinator.com/item?id=50320513) — Hacker News · checked 2026-11-13

Summarized in our own words. Any results described there are the authors’ own, not measured by BotBento.

Verified 2026-11-13: passed every automated gate and a second-model review (kimi-code/k3.1-pro). Automated, not human review. [How verification works](https://botbento.com/usecases/verification/)

By BotBento Editorial · Added 2026-11-13 · Updated 2026-11-13 · [Suggest a correction](https://botbento.com/contact/)

## Related use cases

- [Hybrid code quality and vulnerability remediation](https://botbento.com/usecases/hybrid-code-quality-and-vulnerability-remediation/) — Anchor code audits with static checks to produce targeted patches
- [Exporting terminal coding sessions into pull request notes](https://botbento.com/usecases/exporting-terminal-coding-sessions-into-pull-request/) — Convert raw agent commands, prompts, and file diffs into clean review documentation
- [Review agent-written pull requests against quality gates](https://botbento.com/usecases/review-agent-written-pull-requests-against-quality/) — Check machine-generated diffs for tests, style and structural fit
