[clazy] [Bug 497866] New: Add a detach warning when a Qt container is converted to a QSpan / std::span

Giuseppe D'Angelo bugzilla_noreply at kde.org
Tue Dec 24 14:58:49 GMT 2024


https://bugs.kde.org/show_bug.cgi?id=497866

            Bug ID: 497866
           Summary: Add a detach warning when a Qt container is converted
                    to a QSpan / std::span
    Classification: Developer tools
           Product: clazy
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-bugs at kde.org
          Reporter: dangelog at gmail.com
                CC: smartins at kde.org
  Target Milestone: ---

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list