---
name: flag-dangling-string-view-returns-in-c
description: "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."
license: CC-BY-4.0
compatibility: "Needs access to: GitHub, Terminal, Docs."
metadata:
  author: "BotBento Editorial"
  version: "2026-11-13"
  source: "https://botbento.com/usecases/flag-dangling-string-view-returns-in-c/"
  kind: workflow
  hermes:
    tags: ["cpp", "code-review", "memory-safety", "static-analysis", "string-view"]
    category: coding
---
# Flag dangling string_view returns in C++ patches

Review diffs for views that outlive the temporaries they point at

## When to use

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.

## Steps

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

## Instructions

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.

## Source

Summarized in our own words from [Spooky C++](https://news.ycombinator.com/item?id=50320513) (Hacker News, checked 2026-11-13). Any results described there are the authors’ own.

From the BotBento use-case directory: https://botbento.com/usecases/flag-dangling-string-view-returns-in-c/. Licence: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
