Bug 480325 - Detaching of QList::last and QList::first
Summary: Detaching of QList::last and QList::first
Status: RESOLVED NOT A BUG
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-25 15:40 UTC by aklitzing
Modified: 2024-01-26 11:49 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 aklitzing 2024-01-25 15:40:22 UTC
It seems QList::last and QList::first on Qt6 is a false-positive for Wclazy-detaching-member.

We get for this a warning.

QStringList list;
list << "dummy";
list.last().append("hello");

But it won't call any detaching.

    inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
    inline const T &first() const noexcept { Q_ASSERT(!isEmpty()); return *begin(); }

    inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
    inline const T &last() const noexcept { Q_ASSERT(!isEmpty()); return *(end()-1); }