Bug 497866 - Add a detach warning when a Qt container is converted to a QSpan / std::span
Summary: Add a detach warning when a Qt container is converted to a QSpan / std::span
Status: REPORTED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-24 14:58 UTC by Giuseppe D'Angelo
Modified: 2024-12-24 14:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giuseppe D'Angelo 2024-12-24 14:58:49 UTC
The ranged constructors for QSpan and std::span will call .data() on the input. Even if the element type of the span is const, this will result in a detach if a Qt container is passed, e.g.

```
void f(std::span<const int> s); // will only read, never mutate

QList<int> list = ~~~;
f(list); // unnecessary detach here
```

Clazy should extend its "detach" family of warnings to cover this case, since span is vocabulary types, making the above error-prone.